2022-03-14 13:55:02 +00:00
|
|
|
|
<# LOAD FUNCTIONS #>
|
2022-02-14 16:28:22 +00:00
|
|
|
|
|
2022-03-14 13:55:02 +00:00
|
|
|
|
#Get Working Dir
|
|
|
|
|
$Script:WorkingDir = $PSScriptRoot
|
|
|
|
|
#Get Functions
|
|
|
|
|
Get-ChildItem "$WorkingDir\functions" | ForEach-Object {. $_.FullName}
|
2022-02-14 16:28:22 +00:00
|
|
|
|
|
2022-03-22 13:39:01 +00:00
|
|
|
|
|
2022-02-14 16:28:22 +00:00
|
|
|
|
<# MAIN #>
|
|
|
|
|
|
2022-03-14 13:55:02 +00:00
|
|
|
|
#Run log initialisation function
|
|
|
|
|
Start-Init
|
|
|
|
|
|
|
|
|
|
#Get Notif Locale function
|
2022-03-22 13:39:01 +00:00
|
|
|
|
Get-NotifLocale
|
2022-02-14 16:28:22 +00:00
|
|
|
|
|
|
|
|
|
#Check network connectivity
|
|
|
|
|
if (Test-Network){
|
2022-03-26 21:27:11 +00:00
|
|
|
|
#Get Current Version
|
|
|
|
|
Get-WAUCurrentVersion
|
2022-03-22 13:39:01 +00:00
|
|
|
|
#Check if WAU update feature is enabled
|
2022-03-26 15:02:00 +00:00
|
|
|
|
Get-WAUUpdateStatus
|
2022-03-22 13:39:01 +00:00
|
|
|
|
#If yes then check WAU update
|
2022-03-26 15:02:00 +00:00
|
|
|
|
if ($true -eq $WAUautoupdate){
|
2022-03-22 13:39:01 +00:00
|
|
|
|
#Get Available Version
|
2022-03-26 21:27:11 +00:00
|
|
|
|
Get-WAUAvailableVersion
|
2022-03-22 13:39:01 +00:00
|
|
|
|
#Compare
|
2022-03-27 10:20:33 +00:00
|
|
|
|
if ([version]$WAUAvailableVersion -gt [version]$WAUCurrentVersion){
|
2022-03-22 13:39:01 +00:00
|
|
|
|
#If new version is available, update it
|
2022-03-27 10:20:33 +00:00
|
|
|
|
Write-Log "WAU Available version: $WAUAvailableVersion" "Yellow"
|
2022-03-26 21:27:11 +00:00
|
|
|
|
Update-WAU
|
2022-03-22 13:39:01 +00:00
|
|
|
|
}
|
2022-03-26 21:48:56 +00:00
|
|
|
|
else{
|
2022-03-27 10:20:33 +00:00
|
|
|
|
Write-Log "WAU is up to date." "Green"
|
2022-03-26 21:48:56 +00:00
|
|
|
|
}
|
2022-03-07 01:35:40 +00:00
|
|
|
|
}
|
2022-02-14 16:28:22 +00:00
|
|
|
|
|
2022-04-05 13:17:18 +00:00
|
|
|
|
#Get White or Black list
|
|
|
|
|
Get-WAUConfig
|
|
|
|
|
if ($UseWhiteList){
|
|
|
|
|
$toUpdate = Get-IncludedApps
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
$toSkip = Get-ExcludedApps
|
|
|
|
|
}
|
2022-02-14 16:28:22 +00:00
|
|
|
|
|
|
|
|
|
#Get outdated Winget packages
|
2022-03-22 13:39:01 +00:00
|
|
|
|
$outdated = Get-WingetOutdatedApps
|
2022-02-14 16:28:22 +00:00
|
|
|
|
|
|
|
|
|
#Log list of app to update
|
|
|
|
|
foreach ($app in $outdated){
|
|
|
|
|
#List available updates
|
|
|
|
|
$Log = "Available update : $($app.Name). Current version : $($app.Version). Available version : $($app.AvailableVersion)."
|
|
|
|
|
$Log | Write-host
|
|
|
|
|
$Log | out-file -filepath $LogFile -Append
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-22 13:39:01 +00:00
|
|
|
|
#Count good update installations
|
2022-04-05 13:17:18 +00:00
|
|
|
|
$Script:InstallOK = 0
|
|
|
|
|
|
|
|
|
|
#If White List
|
|
|
|
|
if ($UseWhiteList){
|
|
|
|
|
#For each app, notify and update
|
|
|
|
|
foreach ($app in $outdated){
|
|
|
|
|
if (($toUpdate -contains $app.Id) -and $($app.Version) -ne "Unknown"){
|
|
|
|
|
Update-App $app
|
2022-02-14 16:28:22 +00:00
|
|
|
|
}
|
2022-04-05 13:17:18 +00:00
|
|
|
|
#if current app version is unknown
|
|
|
|
|
elseif($($app.Version) -eq "Unknown"){
|
|
|
|
|
Write-Log "$($app.Name) : Skipped upgrade because current version is 'Unknown'" "Gray"
|
|
|
|
|
}
|
|
|
|
|
#if app is in "excluded list"
|
|
|
|
|
else{
|
|
|
|
|
Write-Log "$($app.Name) : Skipped upgrade because it is not in the included app list" "Gray"
|
2022-02-14 16:28:22 +00:00
|
|
|
|
}
|
2022-02-21 13:26:30 +00:00
|
|
|
|
}
|
2022-04-05 13:17:18 +00:00
|
|
|
|
}
|
|
|
|
|
#If Black List
|
|
|
|
|
else{
|
|
|
|
|
#For each app, notify and update
|
|
|
|
|
foreach ($app in $outdated){
|
|
|
|
|
if (-not ($toSkip -contains $app.Id) -and $($app.Version) -ne "Unknown"){
|
|
|
|
|
Update-App $app
|
|
|
|
|
}
|
|
|
|
|
#if current app version is unknown
|
|
|
|
|
elseif($($app.Version) -eq "Unknown"){
|
|
|
|
|
Write-Log "$($app.Name) : Skipped upgrade because current version is 'Unknown'" "Gray"
|
|
|
|
|
}
|
|
|
|
|
#if app is in "excluded list"
|
|
|
|
|
else{
|
|
|
|
|
Write-Log "$($app.Name) : Skipped upgrade because it is in the excluded app list" "Gray"
|
|
|
|
|
}
|
2022-02-14 16:28:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-04-05 13:17:18 +00:00
|
|
|
|
|
2022-02-14 16:28:22 +00:00
|
|
|
|
if ($InstallOK -gt 0){
|
|
|
|
|
Write-Log "$InstallOK apps updated ! No more update." "Green"
|
|
|
|
|
}
|
|
|
|
|
if ($InstallOK -eq 0){
|
|
|
|
|
Write-Log "No new update." "Green"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#End
|
|
|
|
|
Write-Log "End of process!" "Cyan"
|
2022-02-21 11:46:53 +00:00
|
|
|
|
Start-Sleep 3
|