Windows 7 Portable Usb -

# Validate ISO exists if (-not (Test-Path $IsoPath)) Write-Host "ISO file not found: $IsoPath" -ForegroundColor Red exit 1

# Clean up mount if ($mountDrive -match "^[A-Z]:\\?$" -and $mountDrive -ne $tempExtract -and (Get-PSDrive -Name $mountDrive[0] -ErrorAction SilentlyContinue)) Dismount-DiskImage -ImagePath $IsoPath -ErrorAction SilentlyContinue elseif ($tempExtract -and (Test-Path $tempExtract)) Remove-Item $tempExtract -Recurse -Force -ErrorAction SilentlyContinue windows 7 portable usb

# Helper: Run diskpart script function Invoke-DiskPart param([string[]]$Commands) $script = [string]::Join("`r`n", $Commands) + "`r`nexit" $script # Validate ISO exists if (-not (Test-Path $IsoPath))