function to get mdt drive in post oobe in any case (media or unc)
The last version of rufus put deploy directly on * on a partition, not like the n-1 whose put it to *\deploy\
A solution to correct it:
$erroractionpreference = 'silentlycontinue'
Set-ExecutionPolicy -ExecutionPolicy bypass -force
$tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
$scriptpath = split-path -parent $MyInvocation.MyCommand.Path
$scriptname = $MyInvocation.MyCommand.Name
$OSDComputerName = $tsenv.Value("OSDComputerName")
$DEPLOYMENTMETHOD = $tsenv.Value('DEPLOYMENTMETHOD')
$logpath = $tsenv.Value('logpath')
if(! $logpath){$logpath = "$DEPLOYROOT\logs\$OSDComputerName"}
$Drive = Split-Path -Path $scriptpath -Qualifier
$driveMEDIA = Get-WMIObject Win32_LogicalDisk -Filter "DeviceID='$DriveDeploy'"
if($DEPLOYMENTMETHOD -eq "MEDIA"){
Get-PSDrive -PSProvider 'FileSystem' | ForEach-Object {
$driveLetter = $_.Name
# CD
if ($driveMEDIA.DriveType -eq 5) {Get-ChildItem -Path "$($driveLetter):\Deploy" -Directory | ForEach-Object {if ($_.Name -match "Control") {$DEPLOYROOT = "$($driveLetter):\Deploy"}}}
# USB
elseif ($driveMEDIA.DriveType -eq 2) {Get-ChildItem -Path "$($driveLetter):" -Directory | ForEach-Object {if ($_.Name -match "Control") {$DEPLOYROOT = "$($driveLetter):"}}}
}
$tsenv.Value('DEPLOYROOT') = $DEPLOYROOT
$tsenv.Value('DEPLOYDRIVE') = $DEPLOYROOT
$tsenv.Value('SCRIPTROOT') = "$DEPLOYROOT\SCRIPTS"
$logpath = $logpath.replace("\logs\","\logs\USBKEY\")
}
Commenter cet article