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.DesktopAppInstaller |
Sort-Object Version -DescendingWindowsNotepad | Select-Object -First 1
if (-not $pkg) {
Write-Output "Desktop App Installer packageNotepad not foundinstalled for any user on this host.host - skipped."
exit 10
}
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 $pkg.installer.InstallLocation -ChildPath 'winget.exe'
if (-not (Test-Path $w)) {
Write-Output "winget.exe not found at expected path: $w"
exit 1
}
& $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 }
-1978335215 { Write-Output "Notepad not installed - skipped."; exit 0 }
default { Write-Output "winget exited with code $code"; exit $code }
}