Upgrate WindowsNotepad (Store)

powershell.exe -NoProfile -ExecutionPolicy Bypass -File "notepad-upgrade.ps1"

powershell.exe -NoProfile -ExecutionPolicy Bypass -File "notepad-upgrade.ps1"

 

Get-WmiObject -Class Win32_InstalledStoreProgram | Where-Object { $_.Name -like "*Notepad*" } | Select-Object Name, Version

 

$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 }
}


Revision #6
Created 5 August 2026 18:13:00 by Guest
Updated 5 August 2026 19:29:01 by Guest