Upgrate WindowsNotepad (Store)
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "notepad-upgrade.ps1"
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "notepad-upgrade.ps1"
$pkg = Get-AppxPackage -AllUsers -Name Microsoft.WindowsNotepad | Select-Object -First 1
if (-not $pkg) {
Write-Output "Notepad not installed for any user on this host - skipped."
exit 0
}
Write-Output "Notepad found: version $($pkg.Version) - proceeding with upgrade."
$installer = Get-AppxPackage -AllUsers -Name Microsoft.DesktopAppInstaller |
Sort-Object Version -Descending | Select-Object -First 1
$w = Join-Path -Path $installer.InstallLocation -ChildPath 'winget.exe'
& $w upgrade --id 9MSMLRH6LZF3 --source msstore --accept-package-agreements --accept-source-agreements --silent
$code = $LASTEXITCODE
switch ($code) {
0 { Write-Output "Upgraded successfully."; exit 0 }
-1978335189 { Write-Output "Already at latest version."; exit 0 }
default { Write-Output "winget exited with code $code"; exit $code }
}