Powershell Powershell script to check Windows ISO or USB drive to see what version is on it Updated February 15 2026
Here is a script which will show you which version of Windows you have installed, the version on any USB drives you have attached, and also if you pass it an ISO it will mount it (and leave it mounted) and show the version in that ISO file. This powershell script was created with the assistance of Google Gemini, I tested and iterated until I got a usable output.

Example Output:

Copy to Clipboard --- CURRENT SYSTEM INFO --- Edition: Microsoft Windows 11 Pro Version: 10.0.26200 Build: 26200 --------------------------- ISO TARGETED: C:\Temp\Windows10-22H2.iso Mounting ISO... Checking Mounted ISO (F:\) ... Sources:F:\sources Sources32:F:\x86\sources Sources64:F:\x64\sources Found: F:\x64\sources\install.esd Deployment Image Servicing and Management tool Version: 10.0.26100.5074 Details for image : F:\x64\sources\install.esd Index : 1 Name : Windows 10 Home Description : Windows 10 Home Size : 15,276,446,585 bytes WIM Bootable : No Architecture : x64 Hal : Version : 10.0.19041 ServicePack Build : 3803 ServicePack Level : 0 Edition : Core Installation : Client ProductType : WinNT ProductSuite : Terminal Server System Root : WINDOWS Directories : 28397 Files : 102211 Created : 12/3/2023 - 8:03:21 PM Modified : 2/14/2026 - 7:48:57 PM Languages : en-US (Default) The operation completed successfully. ------------------------------------------- REPAIR SUGGESTION: If the version above matches your Build (26200), use this command: DISM /Online /Cleanup-Image /RestoreHealth /Source:WIM:F:\sources\install.wim:1 /LimitAccess (Note: Change WIM to ESD in the command if the file found was install.esd) Process Complete. Press any key to exit...


This is a two part script. Save the two scripts in the same folder. I then call it like this in an Admin command prompt:
Copy to Clipboard"C:\Tools\Scripts\Powershell\CheckWinISO.bat" "C:\Temp\Windows10-22H2.iso"



Save this as "CheckWinISO.bat".
Copy to Clipboard @echo off :: 1. Set the path as an environment variable so PS doesn't have to parse it as a string set "DROPPED_PATH=%~1" set "PSScript=%~dp0CheckWinISO.ps1" :: 2. Launch PowerShell and tell it to look at that variable powershell -NoProfile -ExecutionPolicy Bypass -Command "& {Start-Process powershell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File \"%PSScript%\"' -Verb RunAs}"



Save this as "CheckWinISO.ps1"
Copy to Clipboard param([string]$DroppedFile) # If the param is empty, check the Environment Variable set in Batch if (-not $DroppedFile) { $DroppedFile = $env:DROPPED_PATH } # Clean up any stray quotes if ($DroppedFile) { $DroppedFile = $DroppedFile.Trim('"').Trim("'") } # 1. Get Current Windows Version Info $currentOS = Get-CimInstance Win32_OperatingSystem $currentBuild = $currentOS.BuildNumber $info = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" $major = $info.CurrentMajorVersionNumber $minor = $info.CurrentMinorVersionNumber $build = $info.CurrentBuild $ubr = $info.UBR $fullBuild = "$major.$minor.$build.$ubr" Write-Host "--- CURRENT SYSTEM INFO ---" -ForegroundColor Cyan Write-Host "Edition: $($currentOS.Caption)" Write-Host "Version: $($currentOS.Version)" Write-Host "Build: $fullBuild" Write-Host "---------------------------`n" function Check-InstallerDrive($DrivePath, $Label) { Write-Host "Checking $Label ($DrivePath) ..." -ForegroundColor White $sources = Join-Path $DrivePath "sources" $sources32 = Join-Path $DrivePath "x86\sources" $sources64 = Join-Path $DrivePath "x64\sources" Write-Host "Sources:$sources" Write-Host "Sources32:$sources32" Write-Host "Sources64:$sources64" if ((Test-Path $sources) -or (Test-Path $sources32) -or (Test-Path $sources64) ) { $found = $false $target = $null # Check for wim or esd if (Test-Path (Join-Path $sources "install.wim")) { $target = Join-Path $sources "install.wim" } elseif (Test-Path (Join-Path $sources "install.esd")) { $target = Join-Path $sources "install.esd" } elseif (Test-Path (Join-Path $sources64 "install.wim")) { $target = Join-Path $sources64 "install.wim" } elseif (Test-Path (Join-Path $sources64 "install.esd")) { $target = Join-Path $sources64 "install.esd" } elseif (Test-Path (Join-Path $sources32 "install.wim")) { $target = Join-Path $sources32 "install.wim" } elseif (Test-Path (Join-Path $sources32 "install.esd")) { $target = Join-Path $sources32 "install.esd" } if ($null -ne $target) { $found = $true Write-Host "Found: $target" -ForegroundColor Green # Run DISM to show info dism /Get-WimInfo /WimFile:"$target" /Index:1 Write-Host "-------------------------------------------" } if (-not $found) { Write-Host "No install.wim/esd found in /sources/." -ForegroundColor Gray } } else { Write-Host "Sources folder not found on $DrivePath" -ForegroundColor Gray } Write-Host "" } # 2. Handle Dropped ISO File if ($DroppedFile -and (Test-Path $DroppedFile) -and ($DroppedFile -like "*.iso")) { Write-Host "ISO TARGETED: $DroppedFile" -ForegroundColor Yellow Write-Host "Mounting ISO..." -ForegroundColor Gray try { # Mount and get the drive letter directly $mount = Mount-DiskImage -ImagePath $DroppedFile -PassThru -ErrorAction Stop $driveLetter = ($mount | Get-Volume).DriveLetter if ($null -ne $driveLetter) { Check-InstallerDrive -DrivePath "$($driveLetter):\" -Label "Mounted ISO" Write-Host "REPAIR SUGGESTION:" -ForegroundColor Magenta Write-Host "If the version above matches your Build ($currentBuild), use this command:" Write-Host "DISM /Online /Cleanup-Image /RestoreHealth /Source:WIM:$($driveLetter):\sources\install.wim:1 /LimitAccess" -ForegroundColor Yellow Write-Host "(Note: Change WIM to ESD in the command if the file found was install.esd)" } else { Write-Host "ISO mounted but no drive letter was assigned." -ForegroundColor Red } } catch { Write-Host "Failed to mount ISO: $($_.Exception.Message)" -ForegroundColor Red } } # 3. Check Removable USB Drives $usbDrives = Get-Volume | Where-Object { $_.DriveType -eq 'Removable' -and $_.DriveLetter -ne $null } if ($null -ne $usbDrives) { foreach ($drive in $usbDrives) { Check-InstallerDrive -DrivePath "$($drive.DriveLetter):\" -Label "USB Drive" } }




©2024 - Some portions of this website are Copyrighted.
Your IP: 216.73.216.119     Referring URL:
Browser: Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Terms and Conditions, Privacy Policy, and Security Policy