Création clé USB bootable Windows via Powershell
La clé USB est en E:
L'ISO Windows est monté sur D
# Select USB drive letter
$usbDriveLetter = "E"
# Format USB drive
Format-Volume -DriveLetter $usbDriveLetter -FileSystem NTFS -NewFileSystemLabel "WinServerUSB" -Confirm:$false | Out-Null
# Select ISO file mount point
$isoMountPointDriveLetter = "D"
# Copy ISO files to USB drive
$source = "$($isoMountPointDriveLetter):\"
$destination = "$($usbDriveLetter):\"
robocopy $source $destination /COPYALL /Z /E /SEC /R:3 /W:3
# Make USB drive bootable
$usbDriveNumber = (Get-WmiObject -Class Win32_DiskDrive | Where-Object {$_.InterfaceType -eq "USB" -and $_.DeviceID -like "*$usbDriveLetter"}).Index
D:\boot\bootsect /nt60 $usbDriveLetter`:
# Task completion notification
Write-Host "USB Creation Complete!"
#Start-Sleep -Seconds 2