# Make Bootable Windows Installation USB -UEFI mode only

exprexs

Member
קוד:
# Make Bootable Windows Installation USB -UEFI mode only - Clean Disk
#
$ISOfilePath = "$Env:UserProfile\Documents\Windows.iso"
$USBDisk = Get-Disk | ? { $_.BusType -eq "USB" } | Select-Object -First 1
$FileSystem = "FAT32"
$PartitionStyle = "GPT"
$Size = (Get-Item -Path $ISOfilePath).Length + 500MB
$Label = "ESD-USB"
#
    # Verify USB Disk is present
If (-not $USBDisk) {
    Write-Host "No USB Disk found" -ForegroundColor Red
    Return
}
#
# Clean & Format the target volume
Clear-Disk -Number $USBDisk.Number -RemoveData -RemoveOEM -Cf:$false
Initialize-Disk -Number $USBDisk.Number -PartitionStyle $PartitionStyle -EA:'0'
Set-Disk -Number $USBDisk.Number -PartitionStyle $PartitionStyle
$Partition = New-Partition -DiskNumber $USBDisk.Number -Size $Size -AssignDriveLetter
$USBVolume = Format-Volume -Partition $Partition -FileSystem $FileSystem -NewFileSystemLabel $Label -Cf:$false -Force -Verbose

# Mount the ISO
$Mount = Mount-DiskImage -ImagePath $ISOfilePath -PassThru
$MountPoint = (Get-Volume -DiskImage $Mount).DriveLetter + ":"

# Copy contents to USB
Write-Host "Copying all ISO contents"
$Source = "$MountPoint\*"
$Destination = "$($USBVolume.DriveLetter):"
Copy-Item -Path $Source -Destination $Destination -Recurse

# Unmount the ISO
Dismount-DiskImage -ImagePath $ISOfilePath

# Check for EFI file
$Drive = "$($USBVolume.DriveLetter):"
$Check = Test-Path "$Drive\EFI\Boot\Bootx64.efi"
If ($Check) {
    Write-Host "Your USB is Bootable for UEFI mode only"
} else {
    Write-Host "Error"
}
#
 
נערך לאחרונה ב:
למעלה