diff --git a/Update-Everything.cmd b/Update-Everything.cmd index 47d85ed..a78a776 100644 --- a/Update-Everything.cmd +++ b/Update-Everything.cmd @@ -1,5 +1,7 @@ taskkill /im powershell.exe /f taskkill /im pwsh.exe /f taskkill /im WindowsTerminal.exe /f +( winget upgrade -e --id Microsoft.WindowsTerminal && +winget upgrade -e --id Microsoft.PowerShell ) || choco upgrade powershell powershell-core microsoft-windows-terminal -y pwsh -nol -nop -noni -file %~dpn0.ps1 diff --git a/Update-Everything.ps1 b/Update-Everything.ps1 index f22dc73..d70e3d9 100644 --- a/Update-Everything.ps1 +++ b/Update-Everything.ps1 @@ -154,23 +154,23 @@ Begin [CmdletBinding()] Param() if($Script:IsNotAdministrator) {Write-Warning "Not running as admin; skipping Essential."; return} Write-Step "$([char]0xD83D)$([char]0xDD1C) Checking for essential updates" - if(Get-Command choco -ErrorAction Ignore) + if(Get-Command winget -ErrorAction Ignore) { - if(choco outdated -r | - ConvertFrom-Csv -Delimiter '|' -Header PackageName,LocalVersion,AvailableVersion | - Where-Object PackageName -in powershell,powershell-core,microsoft-windows-terminal) - {Invoke-EssentialUpdate} - } - elseif(Get-Command winget -ErrorAction Ignore) - { - if(@(winget list Microsoft.WindowsTerminal | + if(@(winget list -e --id Microsoft.WindowsTerminal -s winget --upgrade-available --disable-interactivity --nowarn | Select-Object -Skip 2 -First 1 | Select-String Available && - winget list Microsoft.PowerShell | + winget list -e --id Microsoft.PowerShell -s winget --upgrade-available --disable-interactivity --nowarn | Select-Object -Skip 2 -First 1 | Select-String Available).Count -gt 0) {Invoke-EssentialUpdate} } + elseif(Get-Command choco -ErrorAction Ignore) + { + if(choco outdated -r | + ConvertFrom-Csv -Delimiter '|' -Header PackageName,LocalVersion,AvailableVersion | + Where-Object PackageName -in powershell,powershell-core,microsoft-windows-terminal) + {Invoke-EssentialUpdate} + } else { Write-Verbose 'Neither Chocolatey nor WinGet found, skipping essential updates'