Problem
WinUtil recommends winget upgrade Microsoft.PowerShell. When PowerShell was installed via the MSI at C:\Program Files\PowerShell\7\pwsh.exe, the upgrade fails with:
A newer version was found, but the install technology is different from the current version installed.
Proposed Fix
Detect MSI-installed PowerShell, query the latest release from the PowerShell GitHub API, download the matching PowerShell*-win-x64.msi, run it silently, and remove the temporary installer afterward.
Suggested flow:
$Current = (Get-Command pwsh -ErrorAction SilentlyContinue).Source
if ($Current -like "C:\Program Files\PowerShell\7\pwsh.exe") {
$Release = Invoke-RestMethod "https://api.github.com/repos/PowerShell/PowerShell/releases/latest"
$Asset = $Release.assets |
Where-Object name -match '^PowerShell-.*-win-x64\.msi$' |
Select-Object -First 1
$Msi = Join-Path $env:TEMP $Asset.name
Invoke-WebRequest $Asset.browser_download_url -OutFile $Msi
Start-Process msiexec.exe -ArgumentList "/i `"$Msi`" /passive /norestart" -Wait
Remove-Item $Msi -Force
}
else {
winget upgrade Microsoft.PowerShell
}
This should support future PowerShell versions, require no manual download, preserve the MSI-based installation method, and avoid the recurring winget error.
How to test
- Install PowerShell using the MSI.
- Run the WinUtil upgrade command or script directly.
- Verify that the latest version is installed without the winget error.
- Confirm that the temporary MSI file is removed.
Documentation update
Add a README/INSTALL note:
If PowerShell was installed with the MSI, WinUtil automatically upgrades it via the official MSI installer instead of using winget upgrade.
Problem
WinUtil recommends
winget upgrade Microsoft.PowerShell. When PowerShell was installed via the MSI atC:\Program Files\PowerShell\7\pwsh.exe, the upgrade fails with:Proposed Fix
Detect MSI-installed PowerShell, query the latest release from the PowerShell GitHub API, download the matching
PowerShell*-win-x64.msi, run it silently, and remove the temporary installer afterward.Suggested flow:
This should support future PowerShell versions, require no manual download, preserve the MSI-based installation method, and avoid the recurring winget error.
How to test
Documentation update
Add a README/INSTALL note: