# Get disk number for the USB drive $diskInfo = diskpart /s (New-TemporaryFile | % $_.FullName; Set-Content $_.FullName "list volume`nexit" ) $diskNumberLine = $diskInfo | Select-String -Pattern "$driveLetter\s+" | Select-Object -First 1 if (-not $diskNumberLine) Write-Host "Could not identify disk number for $UsbDriveLetter" -ForegroundColor Red exit 1
Write-Host "=== Windows 7 Bootable USB Creator ===" -ForegroundColor Cyan Write-Host "ISO : $IsoPath" Write-Host "USB : $UsbDriveLetter" Write-Host "WARNING: All data on $UsbDriveLetter will be DESTROYED!" -ForegroundColor Yellow $confirm = Read-Host "Type YES to continue" if ($confirm -ne "YES") Write-Host "Aborted." -ForegroundColor Red exit 0 windows 7 portable usb
# Stop on errors $ErrorActionPreference = "Stop" # Get disk number for the USB drive
#Requires -RunAsAdministrator
if (-not $volNumber) Write-Host "Failed to parse volume number." -ForegroundColor Red exit 1 windows 7 portable usb
# Check if USB drive exists if (-not (Test-Path $drivePath)) Write-Host "Drive $UsbDriveLetter does not exist or is not ready." -ForegroundColor Red exit 1
Support us by disabling this ad blocker.