Update Get-WingetOutdatedApps.ps1

pull/37/head
Romain 2022-04-04 15:54:16 +02:00
parent 8a8511c751
commit 63ef09a01d
1 changed files with 12 additions and 11 deletions

View File

@ -6,22 +6,23 @@ function Get-WingetOutdatedApps {
[string]$AvailableVersion [string]$AvailableVersion
} }
#Get WinGet Location #Get WinGet Path
$WingetCmd = Get-Command winget.exe -ErrorAction SilentlyContinue $WingetPath = (Resolve-Path "C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe").Path
#Get Winget Location in User context
if ($WingetCmd){ if ($WingetCmd){
$script:upgradecmd = $WingetCmd.Source $Script:winget = (Get-Command winget.exe -ErrorAction SilentlyContinue).Source
} }
elseif (Test-Path "C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe\AppInstallerCLI.exe"){ #Get Winget Location in System context (WinGet < 1.17)
#WinGet < 1.17 elseif (Test-Path "$WingetPath\AppInstallerCLI.exe"){
$script:upgradecmd = Resolve-Path "C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe\AppInstallerCLI.exe" | Select-Object -ExpandProperty Path $Script:winget = "$WingetPath\AppInstallerCLI.exe"
} }
elseif (Test-Path "C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe\winget.exe"){ #Get Winget Location in System context (WinGet > 1.17)
#WinGet > 1.17 elseif (Test-Path "$WingetPath\winget.exe"){
$script:upgradecmd = Resolve-Path "C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe\winget.exe" | Select-Object -ExpandProperty Path $Script:winget = "$WingetPath\winget.exe"
} }
else{ else{
Write-Log "Winget not installed !" Write-Log "Winget not installed !" "Red"
return break
} }
#Run winget to list apps and accept source agrements (necessary on first run) #Run winget to list apps and accept source agrements (necessary on first run)