User Tools

Site Tools


usb_windows_installer

[Start] [Cat] [About] [Syntax] [Scraps]


Make a Windows USB Installer in Powershell

# Define Path to the Windows Server 2019 ISO
$ISOFile = "C:\en_windows_server_2019_x64.iso"
 
# Get the USB Drive you want to use, copy the friendly name
Get-Disk | Where BusType -eq "USB"
 
# Get the right USB Drive (You will need to change the FriendlyName)
$USBDrive = Get-Disk | Where FriendlyName -eq "SanDisk Cruzer Glide 3.0"
 
# Replace the Friendly Name to clean the USB Drive (THIS WILL REMOVE EVERYTHING)
$USBDrive | Clear-Disk -RemoveData -Confirm:$true -PassThru
 
# Convert Disk to GPT
$USBDrive | Set-Disk -PartitionStyle GPT
 
# Create partition primary and format to FAT32
$Volume = $USBDrive | New-Partition -UseMaximumSize -AssignDriveLetter | Format-Volume -FileSystem FAT32 -NewFileSystemLabel WS2019
 
# Mount iso
$ISOMounted = Mount-DiskImage -ImagePath $ISOFile -StorageType ISO -PassThru
 
# Driver letter
$ISODriveLetter = ($ISOMounted | Get-Volume).DriveLetter
 
# Copy Files to USB 
Copy-Item -Path ($ISODriveLetter +":\*") -Destination ($Volume.DriveLetter + ":\") -Recurse
 
# Dismount ISO
Dismount-DiskImage -ImagePath $ISOFile
usb_windows_installer.txt ยท Last modified: 2024/11/14 02:30 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki