Optimisations
parent
233f039323
commit
013ab2d7fd
|
@ -0,0 +1,34 @@
|
||||||
|
Function Get-WingetCmd {
|
||||||
|
#Get WinGet Path (if admin context)
|
||||||
|
$ResolveWingetPath = Resolve-Path "C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe"
|
||||||
|
if ($ResolveWingetPath){
|
||||||
|
#If multiple version, pick last one
|
||||||
|
$WingetPath = $ResolveWingetPath[-1].Path
|
||||||
|
}
|
||||||
|
|
||||||
|
#Get Winget Location in User context
|
||||||
|
$WingetCmd = Get-Command winget.exe -ErrorAction SilentlyContinue
|
||||||
|
if ($WingetCmd){
|
||||||
|
$Script:Winget = $WingetCmd.Source
|
||||||
|
}
|
||||||
|
#Get Winget Location in System context (WinGet < 1.17)
|
||||||
|
elseif (Test-Path "$WingetPath\AppInstallerCLI.exe"){
|
||||||
|
$Script:Winget = "$WingetPath\AppInstallerCLI.exe"
|
||||||
|
}
|
||||||
|
#Get Winget Location in System context (WinGet > 1.17)
|
||||||
|
elseif (Test-Path "$WingetPath\winget.exe"){
|
||||||
|
$Script:Winget = "$WingetPath\winget.exe"
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Write-Log "Winget not installed or detected !" "Red"
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
|
||||||
|
#Run winget to list apps and accept source agrements (necessary on first run)
|
||||||
|
& $Winget list --accept-source-agreements | Out-Null
|
||||||
|
|
||||||
|
#Log Winget installed version
|
||||||
|
$WingerVer = & $Winget --version
|
||||||
|
Write-Log "Winget Version: $WingerVer"
|
||||||
|
return $true
|
||||||
|
}
|
|
@ -6,38 +6,6 @@ function Get-WingetOutdatedApps {
|
||||||
[string]$AvailableVersion
|
[string]$AvailableVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
#Get WinGet Path (if admin context)
|
|
||||||
$ResolveWingetPath = Resolve-Path "C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe"
|
|
||||||
if ($ResolveWingetPath){
|
|
||||||
#If multiple version, pick last one
|
|
||||||
$WingetPath = $ResolveWingetPath[-1].Path
|
|
||||||
}
|
|
||||||
|
|
||||||
#Get Winget Location in User context
|
|
||||||
$WingetCmd = Get-Command winget.exe -ErrorAction SilentlyContinue
|
|
||||||
if ($WingetCmd){
|
|
||||||
$Script:Winget = $WingetCmd.Source
|
|
||||||
}
|
|
||||||
#Get Winget Location in System context (WinGet < 1.17)
|
|
||||||
elseif (Test-Path "$WingetPath\AppInstallerCLI.exe"){
|
|
||||||
$Script:Winget = "$WingetPath\AppInstallerCLI.exe"
|
|
||||||
}
|
|
||||||
#Get Winget Location in System context (WinGet > 1.17)
|
|
||||||
elseif (Test-Path "$WingetPath\winget.exe"){
|
|
||||||
$Script:Winget = "$WingetPath\winget.exe"
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
Write-Log "Winget not installed !" "Red"
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
#Run winget to list apps and accept source agrements (necessary on first run)
|
|
||||||
& $Winget list --accept-source-agreements | Out-Null
|
|
||||||
|
|
||||||
#Log Winget installed version
|
|
||||||
$WingerVer = & $Winget --version
|
|
||||||
Write-Log "Winget Version: $WingerVer"
|
|
||||||
|
|
||||||
#Get list of available upgrades on winget format
|
#Get list of available upgrades on winget format
|
||||||
Write-Log "Checking application updates on Winget Repository..." "yellow"
|
Write-Log "Checking application updates on Winget Repository..." "yellow"
|
||||||
$upgradeResult = & $Winget upgrade | Out-String
|
$upgradeResult = & $Winget upgrade | Out-String
|
||||||
|
|
|
@ -16,6 +16,8 @@ Get-NotifLocale
|
||||||
|
|
||||||
#Check network connectivity
|
#Check network connectivity
|
||||||
if (Test-Network){
|
if (Test-Network){
|
||||||
|
$TestWinget = Get-WingetCmd
|
||||||
|
if ($TestWinget){
|
||||||
#Get Current Version
|
#Get Current Version
|
||||||
Get-WAUCurrentVersion
|
Get-WAUCurrentVersion
|
||||||
#Check if WAU update feature is enabled
|
#Check if WAU update feature is enabled
|
||||||
|
@ -99,6 +101,7 @@ if (Test-Network){
|
||||||
if ($InstallOK -eq 0){
|
if ($InstallOK -eq 0){
|
||||||
Write-Log "No new update." "Green"
|
Write-Log "No new update." "Green"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#End
|
#End
|
||||||
|
|
Loading…
Reference in New Issue