VSCode Format

pull/102/head
romanitho 2022-06-10 10:26:41 +02:00
parent 8ee90d8e54
commit a7bd127c43
18 changed files with 152 additions and 152 deletions

View File

@ -47,44 +47,44 @@ Specify the update frequency: Daily (Default), Weekly, Biweekly or Monthly.
[CmdletBinding()] [CmdletBinding()]
param( param(
[Parameter(Mandatory=$False)] [Alias('S')] [Switch] $Silent = $false, [Parameter(Mandatory = $False)] [Alias('S')] [Switch] $Silent = $false,
[Parameter(Mandatory=$False)] [Alias('Path')] [String] $WingetUpdatePath = "$env:ProgramData\Winget-AutoUpdate", [Parameter(Mandatory = $False)] [Alias('Path')] [String] $WingetUpdatePath = "$env:ProgramData\Winget-AutoUpdate",
[Parameter(Mandatory=$False)] [Switch] $DoNotUpdate = $false, [Parameter(Mandatory = $False)] [Switch] $DoNotUpdate = $false,
[Parameter(Mandatory=$False)] [Switch] $DisableWAUAutoUpdate = $false, [Parameter(Mandatory = $False)] [Switch] $DisableWAUAutoUpdate = $false,
[Parameter(Mandatory=$False)] [Switch] $Uninstall = $false, [Parameter(Mandatory = $False)] [Switch] $Uninstall = $false,
[Parameter(Mandatory=$False)] [Switch] $UseWhiteList = $false, [Parameter(Mandatory = $False)] [Switch] $UseWhiteList = $false,
[Parameter(Mandatory=$False)] [ValidateSet("Full","SuccessOnly","None")] [String] $NotificationLevel = "Full", [Parameter(Mandatory = $False)] [ValidateSet("Full", "SuccessOnly", "None")] [String] $NotificationLevel = "Full",
[Parameter(Mandatory=$False)] [Switch] $UpdatesAtLogon = $false, [Parameter(Mandatory = $False)] [Switch] $UpdatesAtLogon = $false,
[Parameter(Mandatory=$False)] [ValidateSet("Daily","Weekly","BiWeekly","Monthly")] [String] $UpdatesInterval = "Daily" [Parameter(Mandatory = $False)] [ValidateSet("Daily", "Weekly", "BiWeekly", "Monthly")] [String] $UpdatesInterval = "Daily"
) )
<# APP INFO #> <# APP INFO #>
$WAUVersion = "1.11.4" $WAUVersion = "1.11.4"
<# FUNCTIONS #> <# FUNCTIONS #>
function Install-Prerequisites{ function Install-Prerequisites {
Write-Host "`nChecking prerequisites..." -ForegroundColor Yellow Write-Host "`nChecking prerequisites..." -ForegroundColor Yellow
#Check if Visual C++ 2019 or 2022 installed #Check if Visual C++ 2019 or 2022 installed
$Visual2019 = "Microsoft Visual C++ 2015-2019 Redistributable*" $Visual2019 = "Microsoft Visual C++ 2015-2019 Redistributable*"
$Visual2022 = "Microsoft Visual C++ 2015-2022 Redistributable*" $Visual2022 = "Microsoft Visual C++ 2015-2022 Redistributable*"
$path = Get-Item HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object {$_.GetValue("DisplayName") -like $Visual2019 -or $_.GetValue("DisplayName") -like $Visual2022} $path = Get-Item HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object { $_.GetValue("DisplayName") -like $Visual2019 -or $_.GetValue("DisplayName") -like $Visual2022 }
#If not installed, ask for installation #If not installed, ask for installation
if (!($path)){ if (!($path)) {
#If -silent option, force installation #If -silent option, force installation
if ($Silent){ if ($Silent) {
$InstallApp = 1 $InstallApp = 1
} }
else{ else {
#Ask for installation #Ask for installation
$MsgBoxTitle = "Winget Prerequisites" $MsgBoxTitle = "Winget Prerequisites"
$MsgBoxContent = "Microsoft Visual C++ 2015-2022 is required. Would you like to install it?" $MsgBoxContent = "Microsoft Visual C++ 2015-2022 is required. Would you like to install it?"
$MsgBoxTimeOut = 60 $MsgBoxTimeOut = 60
$MsgBoxReturn = (New-Object -ComObject "Wscript.Shell").Popup($MsgBoxContent,$MsgBoxTimeOut,$MsgBoxTitle,4+32) $MsgBoxReturn = (New-Object -ComObject "Wscript.Shell").Popup($MsgBoxContent, $MsgBoxTimeOut, $MsgBoxTitle, 4 + 32)
if ($MsgBoxReturn -ne 7) { if ($MsgBoxReturn -ne 7) {
$InstallApp = 1 $InstallApp = 1
} }
@ -93,12 +93,12 @@ function Install-Prerequisites{
} }
} }
#Install if approved #Install if approved
if ($InstallApp -eq 1){ if ($InstallApp -eq 1) {
try{ try {
if((Get-CimInStance Win32_OperatingSystem).OSArchitecture -like "*64*"){ if ((Get-CimInStance Win32_OperatingSystem).OSArchitecture -like "*64*") {
$OSArch = "x64" $OSArch = "x64"
} }
else{ else {
$OSArch = "x86" $OSArch = "x86"
} }
Write-host "-> Downloading VC_redist.$OSArch.exe..." Write-host "-> Downloading VC_redist.$OSArch.exe..."
@ -111,47 +111,47 @@ function Install-Prerequisites{
Remove-Item $Installer -ErrorAction Ignore Remove-Item $Installer -ErrorAction Ignore
Write-host "-> MS Visual C++ 2015-2022 installed successfully" -ForegroundColor Green Write-host "-> MS Visual C++ 2015-2022 installed successfully" -ForegroundColor Green
} }
catch{ catch {
Write-host "-> MS Visual C++ 2015-2022 installation failed." -ForegroundColor Red Write-host "-> MS Visual C++ 2015-2022 installation failed." -ForegroundColor Red
Start-Sleep 3 Start-Sleep 3
} }
} }
else{ else {
Write-host "-> MS Visual C++ 2015-2022 will not be installed." -ForegroundColor Magenta Write-host "-> MS Visual C++ 2015-2022 will not be installed." -ForegroundColor Magenta
} }
} }
else{ else {
Write-Host "Prerequisites checked. OK" -ForegroundColor Green Write-Host "Prerequisites checked. OK" -ForegroundColor Green
} }
} }
function Install-WinGet{ function Install-WinGet {
Write-Host "`nChecking if Winget is installed" -ForegroundColor Yellow Write-Host "`nChecking if Winget is installed" -ForegroundColor Yellow
#Check Package Install #Check Package Install
$TestWinGet = Get-AppxProvisionedPackage -Online | Where-Object {$_.DisplayName -eq "Microsoft.DesktopAppInstaller"} $TestWinGet = Get-AppxProvisionedPackage -Online | Where-Object { $_.DisplayName -eq "Microsoft.DesktopAppInstaller" }
If([Version]$TestWinGet.Version -ge "2022.519.1908.0") { If ([Version]$TestWinGet.Version -ge "2022.519.1908.0") {
Write-Host "WinGet is Installed" -ForegroundColor Green Write-Host "WinGet is Installed" -ForegroundColor Green
} }
Else{ Else {
#Download WinGet MSIXBundle #Download WinGet MSIXBundle
Write-Host "-> Not installed. Downloading WinGet..." Write-Host "-> Not installed. Downloading WinGet..."
$WinGetURL = "https://github.com/microsoft/winget-cli/releases/download/v1.3.1391-preview/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" $WinGetURL = "https://github.com/microsoft/winget-cli/releases/download/v1.3.1391-preview/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle"
$WebClient=New-Object System.Net.WebClient $WebClient = New-Object System.Net.WebClient
$WebClient.DownloadFile($WinGetURL, "$PSScriptRoot\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle") $WebClient.DownloadFile($WinGetURL, "$PSScriptRoot\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle")
#Install WinGet MSIXBundle #Install WinGet MSIXBundle
try{ try {
Write-Host "-> Installing Winget MSIXBundle for App Installer..." Write-Host "-> Installing Winget MSIXBundle for App Installer..."
Add-AppxProvisionedPackage -Online -PackagePath "$PSScriptRoot\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -SkipLicense | Out-Null Add-AppxProvisionedPackage -Online -PackagePath "$PSScriptRoot\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -SkipLicense | Out-Null
Write-Host "Installed Winget MSIXBundle for App Installer" -ForegroundColor Green Write-Host "Installed Winget MSIXBundle for App Installer" -ForegroundColor Green
} }
catch{ catch {
Write-Host "Failed to intall Winget MSIXBundle for App Installer..." -ForegroundColor Red Write-Host "Failed to intall Winget MSIXBundle for App Installer..." -ForegroundColor Red
} }
@ -162,13 +162,13 @@ function Install-WinGet{
} }
function Install-WingetAutoUpdate{ function Install-WingetAutoUpdate {
Write-Host "`nInstalling WAU..." -ForegroundColor Yellow Write-Host "`nInstalling WAU..." -ForegroundColor Yellow
try{ try {
#Copy files to location (and clean old install) #Copy files to location (and clean old install)
if (!(Test-Path $WingetUpdatePath)){ if (!(Test-Path $WingetUpdatePath)) {
New-Item -ItemType Directory -Force -Path $WingetUpdatePath | Out-Null New-Item -ItemType Directory -Force -Path $WingetUpdatePath | Out-Null
} }
else { else {
@ -177,11 +177,11 @@ function Install-WingetAutoUpdate{
Copy-Item -Path "$PSScriptRoot\Winget-AutoUpdate\*" -Destination $WingetUpdatePath -Recurse -Force -ErrorAction SilentlyContinue Copy-Item -Path "$PSScriptRoot\Winget-AutoUpdate\*" -Destination $WingetUpdatePath -Recurse -Force -ErrorAction SilentlyContinue
#White List or Black List apps #White List or Black List apps
if ($UseWhiteList){ if ($UseWhiteList) {
if (Test-Path "$PSScriptRoot\included_apps.txt"){ if (Test-Path "$PSScriptRoot\included_apps.txt") {
Copy-Item -Path "$PSScriptRoot\included_apps.txt" -Destination $WingetUpdatePath -Recurse -Force -ErrorAction SilentlyContinue Copy-Item -Path "$PSScriptRoot\included_apps.txt" -Destination $WingetUpdatePath -Recurse -Force -ErrorAction SilentlyContinue
} }
else{ else {
New-Item -Path $WingetUpdatePath -Name "included_apps.txt" -ItemType "file" -ErrorAction SilentlyContinue | Out-Null New-Item -Path $WingetUpdatePath -Name "included_apps.txt" -ItemType "file" -ErrorAction SilentlyContinue | Out-Null
} }
} }
@ -196,19 +196,19 @@ function Install-WingetAutoUpdate{
# Settings for the scheduled task for Updates # Settings for the scheduled task for Updates
$taskAction = New-ScheduledTaskAction Execute "powershell.exe" -Argument "-NoProfile -ExecutionPolicy Bypass -File `"$($WingetUpdatePath)\winget-upgrade.ps1`"" $taskAction = New-ScheduledTaskAction Execute "powershell.exe" -Argument "-NoProfile -ExecutionPolicy Bypass -File `"$($WingetUpdatePath)\winget-upgrade.ps1`""
$taskTriggers = @() $taskTriggers = @()
if ($UpdatesAtLogon){ if ($UpdatesAtLogon) {
$tasktriggers += New-ScheduledTaskTrigger -AtLogOn $tasktriggers += New-ScheduledTaskTrigger -AtLogOn
} }
if ($UpdatesInterval -eq "Daily"){ if ($UpdatesInterval -eq "Daily") {
$tasktriggers += New-ScheduledTaskTrigger -Daily -At 6AM $tasktriggers += New-ScheduledTaskTrigger -Daily -At 6AM
} }
elseif ($UpdatesInterval -eq "Weekly"){ elseif ($UpdatesInterval -eq "Weekly") {
$tasktriggers += New-ScheduledTaskTrigger -Weekly -At 6AM -DaysOfWeek 2 $tasktriggers += New-ScheduledTaskTrigger -Weekly -At 6AM -DaysOfWeek 2
} }
elseif ($UpdatesInterval -eq "BiWeekly"){ elseif ($UpdatesInterval -eq "BiWeekly") {
$tasktriggers += New-ScheduledTaskTrigger -Weekly -At 6AM -DaysOfWeek 2 -WeeksInterval 2 $tasktriggers += New-ScheduledTaskTrigger -Weekly -At 6AM -DaysOfWeek 2 -WeeksInterval 2
} }
elseif ($UpdatesInterval -eq "Monthly"){ elseif ($UpdatesInterval -eq "Monthly") {
$tasktriggers += New-ScheduledTaskTrigger -Weekly -At 6AM -DaysOfWeek 2 -WeeksInterval 4 $tasktriggers += New-ScheduledTaskTrigger -Weekly -At 6AM -DaysOfWeek 2 -WeeksInterval 4
} }
$taskUserPrincipal = New-ScheduledTaskPrincipal -UserId S-1-5-18 -RunLevel Highest $taskUserPrincipal = New-ScheduledTaskPrincipal -UserId S-1-5-18 -RunLevel Highest
@ -258,23 +258,23 @@ function Install-WingetAutoUpdate{
#Run Winget ? #Run Winget ?
Start-WingetAutoUpdate Start-WingetAutoUpdate
} }
catch{ catch {
Write-host "WAU Installation failed! Run me with admin rights" -ForegroundColor Red Write-host "WAU Installation failed! Run me with admin rights" -ForegroundColor Red
Start-sleep 1 Start-sleep 1
return $False return $False
} }
} }
function Uninstall-WingetAutoUpdate{ function Uninstall-WingetAutoUpdate {
Write-Host "`nUninstalling WAU..." -ForegroundColor Yellow Write-Host "`nUninstalling WAU..." -ForegroundColor Yellow
try{ try {
#Get registry install location #Get registry install location
$InstallLocation = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocation $InstallLocation = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocation
#Check if installed location exists and delete #Check if installed location exists and delete
if (Test-Path ($InstallLocation)){ if (Test-Path ($InstallLocation)) {
Remove-Item $InstallLocation -Force -Recurse Remove-Item $InstallLocation -Force -Recurse
Get-ScheduledTask -TaskName "Winget-AutoUpdate" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False Get-ScheduledTask -TaskName "Winget-AutoUpdate" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False
Get-ScheduledTask -TaskName "Winget-AutoUpdate-Notify" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False Get-ScheduledTask -TaskName "Winget-AutoUpdate-Notify" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False
@ -288,46 +288,46 @@ function Uninstall-WingetAutoUpdate{
Write-host "$InstallLocation not found! Uninstallation failed!" -ForegroundColor Red Write-host "$InstallLocation not found! Uninstallation failed!" -ForegroundColor Red
} }
} }
catch{ catch {
Write-host "Uninstallation failed! Run as admin ?" -ForegroundColor Red Write-host "Uninstallation failed! Run as admin ?" -ForegroundColor Red
Start-sleep 1 Start-sleep 1
} }
} }
function Start-WingetAutoUpdate{ function Start-WingetAutoUpdate {
#If -DoNotUpdate is true, skip. #If -DoNotUpdate is true, skip.
if (!($DoNotUpdate)){ if (!($DoNotUpdate)) {
#If -Silent, run Winget-AutoUpdate now #If -Silent, run Winget-AutoUpdate now
if ($Silent){ if ($Silent) {
$RunWinget = 1
}
#Ask for WingetAutoUpdate
else {
$MsgBoxTitle = "Winget-AutoUpdate"
$MsgBoxContent = "Would you like to run Winget-AutoUpdate now?"
$MsgBoxTimeOut = 60
$MsgBoxReturn = (New-Object -ComObject "Wscript.Shell").Popup($MsgBoxContent, $MsgBoxTimeOut, $MsgBoxTitle, 4 + 32)
if ($MsgBoxReturn -ne 7) {
$RunWinget = 1 $RunWinget = 1
} }
#Ask for WingetAutoUpdate else {
else{ $RunWinget = 0
$MsgBoxTitle = "Winget-AutoUpdate"
$MsgBoxContent = "Would you like to run Winget-AutoUpdate now?"
$MsgBoxTimeOut = 60
$MsgBoxReturn = (New-Object -ComObject "Wscript.Shell").Popup($MsgBoxContent,$MsgBoxTimeOut,$MsgBoxTitle,4+32)
if ($MsgBoxReturn -ne 7) {
$RunWinget = 1
}
else {
$RunWinget = 0
}
} }
if ($RunWinget -eq 1){ }
try{ if ($RunWinget -eq 1) {
try {
Write-host "`nRunning Winget-AutoUpdate..." -ForegroundColor Yellow Write-host "`nRunning Winget-AutoUpdate..." -ForegroundColor Yellow
Get-ScheduledTask -TaskName "Winget-AutoUpdate" -ErrorAction SilentlyContinue | Start-ScheduledTask -ErrorAction SilentlyContinue Get-ScheduledTask -TaskName "Winget-AutoUpdate" -ErrorAction SilentlyContinue | Start-ScheduledTask -ErrorAction SilentlyContinue
while ((Get-ScheduledTask -TaskName "Winget-AutoUpdate").State -ne 'Ready') { while ((Get-ScheduledTask -TaskName "Winget-AutoUpdate").State -ne 'Ready') {
Start-Sleep 1 Start-Sleep 1
} }
} }
catch{ catch {
Write-host "Failed to run Winget-AutoUpdate..." -ForegroundColor Red Write-host "Failed to run Winget-AutoUpdate..." -ForegroundColor Red
} }
} }
} }
else{ else {
Write-host "Skip running Winget-AutoUpdate" Write-host "Skip running Winget-AutoUpdate"
} }
} }
@ -348,7 +348,7 @@ Write-Host "`t Winget-AutoUpdate $WAUVersion`n" -ForegroundColor
Write-Host "`t https://github.com/Romanitho/Winget-AutoUpdate`n" -ForegroundColor Magenta Write-Host "`t https://github.com/Romanitho/Winget-AutoUpdate`n" -ForegroundColor Magenta
Write-Host "`t________________________________________________________`n`n" Write-Host "`t________________________________________________________`n`n"
if (!$Uninstall){ if (!$Uninstall) {
Write-host "Installing WAU to $WingetUpdatePath\" Write-host "Installing WAU to $WingetUpdatePath\"
Install-Prerequisites Install-Prerequisites
Install-WinGet Install-WinGet

View File

@ -11,13 +11,13 @@ Write-Host "`t Winget-AutoUpdate`n" -ForegroundColor Cyan
Write-Host "`t https://github.com/Romanitho/Winget-AutoUpdate`n" -ForegroundColor Magenta Write-Host "`t https://github.com/Romanitho/Winget-AutoUpdate`n" -ForegroundColor Magenta
Write-Host "`t________________________________________________________`n`n" Write-Host "`t________________________________________________________`n`n"
try{ try {
Write-host "Uninstalling WAU..." -ForegroundColor Yellow Write-host "Uninstalling WAU..." -ForegroundColor Yellow
#Get registry install location #Get registry install location
$InstallLocation = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocation $InstallLocation = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocation
#Check if installed location exists and delete #Check if installed location exists and delete
if (Test-Path ($InstallLocation)){ if (Test-Path ($InstallLocation)) {
Remove-Item "$InstallLocation\*" -Force -Recurse -Exclude "*.log" Remove-Item "$InstallLocation\*" -Force -Recurse -Exclude "*.log"
Get-ScheduledTask -TaskName "Winget-AutoUpdate" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False Get-ScheduledTask -TaskName "Winget-AutoUpdate" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False
Get-ScheduledTask -TaskName "Winget-AutoUpdate-Notify" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False Get-ScheduledTask -TaskName "Winget-AutoUpdate-Notify" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False
@ -33,7 +33,7 @@ try{
Write-host "$InstallLocation not found! Uninstallation failed!" -ForegroundColor Red Write-host "$InstallLocation not found! Uninstallation failed!" -ForegroundColor Red
} }
} }
catch{ catch {
Write-host "`nUninstallation failed! Run as admin ?" -ForegroundColor Red Write-host "`nUninstallation failed! Run as admin ?" -ForegroundColor Red
} }

View File

@ -1,21 +1,19 @@
#Function to configure prefered scope option as Machine #Function to configure prefered scope option as Machine
function Add-ScopeMachine ($SettingsPath) { function Add-ScopeMachine ($SettingsPath) {
if (Test-Path $SettingsPath){ if (Test-Path $SettingsPath) {
$ConfigFile = Get-Content -Path $SettingsPath | Where-Object {$_ -notmatch '//'} | ConvertFrom-Json $ConfigFile = Get-Content -Path $SettingsPath | Where-Object { $_ -notmatch '//' } | ConvertFrom-Json
} }
if (!$ConfigFile){ if (!$ConfigFile) {
$ConfigFile = @{} $ConfigFile = @{}
} }
if ($ConfigFile.installBehavior.preferences.scope){ if ($ConfigFile.installBehavior.preferences.scope) {
$ConfigFile.installBehavior.preferences.scope = "Machine" $ConfigFile.installBehavior.preferences.scope = "Machine"
} }
else { else {
Add-Member -InputObject $ConfigFile -MemberType NoteProperty -Name 'installBehavior' -Value $( $Scope = New-Object PSObject -Property $(@{scope = "Machine" })
New-Object PSObject -Property $(@{preferences = $( $Preference = New-Object PSObject -Property $(@{preferences = $Scope })
New-Object PSObject -Property $(@{scope = "Machine"})) Add-Member -InputObject $ConfigFile -MemberType NoteProperty -Name 'installBehavior' -Value $Preference -Force
})
) -Force
} }
$ConfigFile | ConvertTo-Json | Out-File $SettingsPath -Encoding utf8 -Force $ConfigFile | ConvertTo-Json | Out-File $SettingsPath -Encoding utf8 -Force

View File

@ -1,8 +1,8 @@
#Function to get Black List apps #Function to get Black List apps
function Get-ExcludedApps{ function Get-ExcludedApps {
if (Test-Path "$WorkingDir\excluded_apps.txt"){ if (Test-Path "$WorkingDir\excluded_apps.txt") {
return Get-Content -Path "$WorkingDir\excluded_apps.txt" return Get-Content -Path "$WorkingDir\excluded_apps.txt"

View File

@ -1,8 +1,8 @@
#Function to get White List apps #Function to get White List apps
function Get-IncludedApps{ function Get-IncludedApps {
if (Test-Path "$WorkingDir\included_apps.txt"){ if (Test-Path "$WorkingDir\included_apps.txt") {
return Get-Content -Path "$WorkingDir\included_apps.txt" return Get-Content -Path "$WorkingDir\included_apps.txt"

View File

@ -9,12 +9,12 @@ Function Get-NotifLocale {
$TestOSLocalPath = "$WorkingDir\locale\$($OSLocale.Name).xml" $TestOSLocalPath = "$WorkingDir\locale\$($OSLocale.Name).xml"
#Set OS Local if file exists #Set OS Local if file exists
if(Test-Path $TestOSLocalPath){ if (Test-Path $TestOSLocalPath) {
$LocaleDisplayName = $OSLocale.DisplayName $LocaleDisplayName = $OSLocale.DisplayName
$LocaleFile = $TestOSLocalPath $LocaleFile = $TestOSLocalPath
} }
#Set English if file doesn't exist #Set English if file doesn't exist
else{ else {
$LocaleDisplayName = "English" $LocaleDisplayName = "English"
$LocaleFile = "$WorkingDir\locale\en.xml" $LocaleFile = "$WorkingDir\locale\en.xml"
} }

View File

@ -19,6 +19,6 @@ function Get-WAUAvailableVersion {
} }
return ((Invoke-WebRequest $WAUurl -UseBasicParsing | ConvertFrom-Json)[0].tag_name).Replace("v","") return ((Invoke-WebRequest $WAUurl -UseBasicParsing | ConvertFrom-Json)[0].tag_name).Replace("v", "")
} }

View File

@ -4,25 +4,25 @@ Function Get-WingetCmd {
#Get WinGet Path (if admin context) #Get WinGet Path (if admin context)
$ResolveWingetPath = Resolve-Path "C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe" $ResolveWingetPath = Resolve-Path "C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe"
if ($ResolveWingetPath){ if ($ResolveWingetPath) {
#If multiple version, pick last one #If multiple version, pick last one
$WingetPath = $ResolveWingetPath[-1].Path $WingetPath = $ResolveWingetPath[-1].Path
} }
#Get Winget Location in User context #Get Winget Location in User context
$WingetCmd = Get-Command winget.exe -ErrorAction SilentlyContinue $WingetCmd = Get-Command winget.exe -ErrorAction SilentlyContinue
if ($WingetCmd){ if ($WingetCmd) {
$Script:Winget = $WingetCmd.Source $Script:Winget = $WingetCmd.Source
} }
#Get Winget Location in System context (WinGet < 1.17) #Get Winget Location in System context (WinGet < 1.17)
elseif (Test-Path "$WingetPath\AppInstallerCLI.exe"){ elseif (Test-Path "$WingetPath\AppInstallerCLI.exe") {
$Script:Winget = "$WingetPath\AppInstallerCLI.exe" $Script:Winget = "$WingetPath\AppInstallerCLI.exe"
} }
#Get Winget Location in System context (WinGet > 1.17) #Get Winget Location in System context (WinGet > 1.17)
elseif (Test-Path "$WingetPath\winget.exe"){ elseif (Test-Path "$WingetPath\winget.exe") {
$Script:Winget = "$WingetPath\winget.exe" $Script:Winget = "$WingetPath\winget.exe"
} }
else{ else {
Write-Log "Winget not installed or detected !" "Red" Write-Log "Winget not installed or detected !" "Red"
return $false return $false
} }

View File

@ -13,16 +13,16 @@ function Get-WingetOutdatedApps {
$upgradeResult = & $Winget upgrade | Out-String $upgradeResult = & $Winget upgrade | Out-String
#Start Convertion of winget format to an array. Check if "-----" exists #Start Convertion of winget format to an array. Check if "-----" exists
if (!($upgradeResult -match "-----")){ if (!($upgradeResult -match "-----")) {
return return
} }
#Split winget output to lines #Split winget output to lines
$lines = $upgradeResult.Split([Environment]::NewLine) | Where-Object {$_} $lines = $upgradeResult.Split([Environment]::NewLine) | Where-Object { $_ }
# Find the line that starts with "------" # Find the line that starts with "------"
$fl = 0 $fl = 0
while (-not $lines[$fl].StartsWith("-----")){ while (-not $lines[$fl].StartsWith("-----")) {
$fl++ $fl++
} }
@ -40,9 +40,9 @@ function Get-WingetOutdatedApps {
# Now cycle in real package and split accordingly # Now cycle in real package and split accordingly
$upgradeList = @() $upgradeList = @()
For ($i = $fl + 2; $i -le $lines.Length; $i++){ For ($i = $fl + 2; $i -le $lines.Length; $i++) {
$line = $lines[$i] $line = $lines[$i]
if ($line.Length -gt ($sourceStart+5) -and -not $line.Contains("--include-unknown")){ if ($line.Length -gt ($sourceStart + 5) -and -not $line.Contains("--include-unknown")) {
$software = [Software]::new() $software = [Software]::new()
$software.Name = $line.Substring(0, $idStart).TrimEnd() $software.Name = $line.Substring(0, $idStart).TrimEnd()
$software.Id = $line.Substring($idStart, $versionStart - $idStart).TrimEnd() $software.Id = $line.Substring($idStart, $versionStart - $idStart).TrimEnd()

View File

@ -7,7 +7,7 @@ function Invoke-PostUpdateActions {
#Reset Winget Sources #Reset Winget Sources
$ResolveWingetPath = Resolve-Path "$env:programfiles\WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe\winget.exe" $ResolveWingetPath = Resolve-Path "$env:programfiles\WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe\winget.exe"
if ($ResolveWingetPath){ if ($ResolveWingetPath) {
#If multiple version, pick last one #If multiple version, pick last one
$WingetPath = $ResolveWingetPath[-1].Path $WingetPath = $ResolveWingetPath[-1].Path
& $WingetPath source reset --force & $WingetPath source reset --force
@ -52,10 +52,10 @@ function Invoke-PostUpdateActions {
$WAUConfigPath = "$WorkingDir\config\config.xml" $WAUConfigPath = "$WorkingDir\config\config.xml"
if (test-path $WAUConfigPath) { if (test-path $WAUConfigPath) {
[xml]$Config = Get-Content $WAUConfigPath -Encoding UTF8 -ErrorAction SilentlyContinue [xml]$Config = Get-Content $WAUConfigPath -Encoding UTF8 -ErrorAction SilentlyContinue
if ($Config.app.WAUautoupdate -eq "False") {New-ItemProperty $regPath -Name WAU_DisableAutoUpdate -Value 1 -Force} if ($Config.app.WAUautoupdate -eq "False") { New-ItemProperty $regPath -Name WAU_DisableAutoUpdate -Value 1 -Force }
if ($Config.app.NotificationLevel) {New-ItemProperty $regPath -Name WAU_NotificationLevel -Value $Config.app.NotificationLevel -Force} if ($Config.app.NotificationLevel) { New-ItemProperty $regPath -Name WAU_NotificationLevel -Value $Config.app.NotificationLevel -Force }
if ($Config.app.UseWAUWhiteList -eq "True") {New-ItemProperty $regPath -Name WAU_UseWhiteList -Value 1 -PropertyType DWord -Force} if ($Config.app.UseWAUWhiteList -eq "True") { New-ItemProperty $regPath -Name WAU_UseWhiteList -Value 1 -PropertyType DWord -Force }
if ($Config.app.WAUprerelease -eq "True") {New-ItemProperty $regPath -Name WAU_UpdatePrerelease -Value 1 -PropertyType DWord -Force} if ($Config.app.WAUprerelease -eq "True") { New-ItemProperty $regPath -Name WAU_UpdatePrerelease -Value 1 -PropertyType DWord -Force }
#Remove file once converted #Remove file once converted
Remove-Item $WAUConfigPath -Force -Confirm:$false Remove-Item $WAUConfigPath -Force -Confirm:$false
@ -70,7 +70,7 @@ function Invoke-PostUpdateActions {
"$WorkingDir\functions\Get-WAUCurrentVersion.ps1", "$WorkingDir\functions\Get-WAUCurrentVersion.ps1",
"$WorkingDir\functions\Get-WAUUpdateStatus.ps1" "$WorkingDir\functions\Get-WAUUpdateStatus.ps1"
) )
foreach ($FileName in $FileNames){ foreach ($FileName in $FileNames) {
if (Test-Path $FileName) { if (Test-Path $FileName) {
Remove-Item $FileName -Force -Confirm:$false Remove-Item $FileName -Force -Confirm:$false

View File

@ -10,11 +10,11 @@ function Start-Init {
$Log | Write-host $Log | Write-host
#Logs initialisation if admin #Logs initialisation if admin
try{ try {
$LogPath = "$WorkingDir\logs" $LogPath = "$WorkingDir\logs"
if (!(Test-Path $LogPath)){ if (!(Test-Path $LogPath)) {
New-Item -ItemType Directory -Force -Path $LogPath New-Item -ItemType Directory -Force -Path $LogPath
} }
@ -24,11 +24,11 @@ function Start-Init {
} }
#Logs initialisation if non-admin #Logs initialisation if non-admin
catch{ catch {
$LogPath = "$env:USERPROFILE\Winget-AutoUpdate\logs" $LogPath = "$env:USERPROFILE\Winget-AutoUpdate\logs"
if (!(Test-Path $LogPath)){ if (!(Test-Path $LogPath)) {
New-Item -ItemType Directory -Force -Path $LogPath New-Item -ItemType Directory -Force -Path $LogPath
} }

View File

@ -1,6 +1,6 @@
#Function to send notifications to user #Function to send notifications to user
function Start-NotifTask ($Title,$Message,$MessageType,$Balise) { function Start-NotifTask ($Title, $Message, $MessageType, $Balise) {
if (($WAUConfig.WAU_NotificationLevel -eq "Full") -or ($WAUConfig.WAU_NotificationLevel -eq "SuccessOnly" -and $MessageType -eq "Success")) { if (($WAUConfig.WAU_NotificationLevel -eq "Full") -or ($WAUConfig.WAU_NotificationLevel -eq "SuccessOnly" -and $MessageType -eq "Success")) {
@ -22,11 +22,11 @@ function Start-NotifTask ($Title,$Message,$MessageType,$Balise) {
$currentPrincipal = [bool](([System.Security.Principal.WindowsIdentity]::GetCurrent()).groups -match "S-1-5-4") $currentPrincipal = [bool](([System.Security.Principal.WindowsIdentity]::GetCurrent()).groups -match "S-1-5-4")
#if not "Interactive" user, run as system #if not "Interactive" user, run as system
if ($currentPrincipal -eq $false){ if ($currentPrincipal -eq $false) {
#Save XML to File #Save XML to File
$ToastTemplateLocation = "$env:ProgramData\Winget-AutoUpdate\config\" $ToastTemplateLocation = "$env:ProgramData\Winget-AutoUpdate\config\"
if (!(Test-Path $ToastTemplateLocation)){ if (!(Test-Path $ToastTemplateLocation)) {
New-Item -ItemType Directory -Force -Path $ToastTemplateLocation New-Item -ItemType Directory -Force -Path $ToastTemplateLocation
} }
$ToastTemplate.Save("$ToastTemplateLocation\notif.xml") $ToastTemplate.Save("$ToastTemplateLocation\notif.xml")
@ -36,7 +36,7 @@ function Start-NotifTask ($Title,$Message,$MessageType,$Balise) {
} }
#else, run as connected user #else, run as connected user
else{ else {
#Load Assemblies #Load Assemblies
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null [Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null

View File

@ -1,22 +1,22 @@
#Function to check if modification exists in 'mods' directory #Function to check if modification exists in 'mods' directory
function Test-Mods ($app){ function Test-Mods ($app) {
#Takes care of a null situation #Takes care of a null situation
$ModsInstall = $null $ModsInstall = $null
$ModsUpgrade = $null $ModsUpgrade = $null
$Mods = "$WorkingDir\mods" $Mods = "$WorkingDir\mods"
if (Test-Path "$Mods\$app-*"){ if (Test-Path "$Mods\$app-*") {
if (Test-Path "$Mods\$app-install.ps1"){ if (Test-Path "$Mods\$app-install.ps1") {
$ModsInstall = "$Mods\$app-install.ps1" $ModsInstall = "$Mods\$app-install.ps1"
$ModsUpgrade = "$Mods\$app-install.ps1" $ModsUpgrade = "$Mods\$app-install.ps1"
} }
if (Test-Path "$Mods\$app-upgrade.ps1"){ if (Test-Path "$Mods\$app-upgrade.ps1") {
$ModsUpgrade = "$Mods\$app-upgrade.ps1" $ModsUpgrade = "$Mods\$app-upgrade.ps1"
} }
} }
return $ModsInstall,$ModsUpgrade return $ModsInstall, $ModsUpgrade
} }

View File

@ -7,23 +7,23 @@ function Test-Network {
#Test connectivity during 30 min then timeout #Test connectivity during 30 min then timeout
Write-Log "Checking internet connection..." "Yellow" Write-Log "Checking internet connection..." "Yellow"
While ($timeout -lt 1800){ While ($timeout -lt 1800) {
$TestNetwork = Test-NetConnection 8.8.8.8 -Port 443 -InformationLevel Quiet $TestNetwork = Test-NetConnection 8.8.8.8 -Port 443 -InformationLevel Quiet
if ($TestNetwork){ if ($TestNetwork) {
Write-Log "Connected !" "Green" Write-Log "Connected !" "Green"
return $true return $true
} }
else{ else {
Start-Sleep 10 Start-Sleep 10
$timeout += 10 $timeout += 10
#Send Warning Notif if no connection for 5 min #Send Warning Notif if no connection for 5 min
if ($timeout -eq 300){ if ($timeout -eq 300) {
Write-Log "Notify 'No connection' sent." "Yellow" Write-Log "Notify 'No connection' sent." "Yellow"
$Title = $NotifLocale.local.outputs.output[0].title $Title = $NotifLocale.local.outputs.output[0].title
$Message = $NotifLocale.local.outputs.output[0].message $Message = $NotifLocale.local.outputs.output[0].message

View File

@ -21,7 +21,7 @@ Function Update-App ($app) {
$FailedToUpgrade = $false $FailedToUpgrade = $false
#Check if mods exist #Check if mods exist
$ModsInstall, $ModsUpgrade = Test-Mods $($app.Id) $ModsInstall, $ModsUpgrade = Test-Mods $($app.Id)
foreach ($CheckApp in $CheckOutdated){ foreach ($CheckApp in $CheckOutdated) {
if ($($CheckApp.Id) -eq $($app.Id)) { if ($($CheckApp.Id) -eq $($app.Id)) {
#If app failed to upgrade, run Install command #If app failed to upgrade, run Install command
@ -29,12 +29,12 @@ Function Update-App ($app) {
#Check if application installed properly #Check if application installed properly
$CheckOutdated2 = Get-WingetOutdatedApps $CheckOutdated2 = Get-WingetOutdatedApps
foreach ($CheckApp2 in $CheckOutdated2){ foreach ($CheckApp2 in $CheckOutdated2) {
if ($($CheckApp2.Id) -eq $($app.Id)) { if ($($CheckApp2.Id) -eq $($app.Id)) {
$FailedToUpgrade = $true $FailedToUpgrade = $true
} }
else { else {
if ($ModsInstall){ if ($ModsInstall) {
Write-Log "Modifications for $($app.Id) after install are being applied..." "Yellow" Write-Log "Modifications for $($app.Id) after install are being applied..." "Yellow"
& "$ModsInstall" & "$ModsInstall"
} }
@ -42,7 +42,7 @@ Function Update-App ($app) {
} }
} }
else { else {
if ($ModsUpgrade){ if ($ModsUpgrade) {
Write-Log "Modifications for $($app.Id) after upgrade are being applied..." "Yellow" Write-Log "Modifications for $($app.Id) after upgrade are being applied..." "Yellow"
& "$ModsUpgrade" & "$ModsUpgrade"
} }
@ -52,7 +52,7 @@ Function Update-App ($app) {
Write-Log "########## WINGET UPGRADE PROCESS FINISHED FOR APPLICATION ID '$($App.Id)' ##########" "Gray" Write-Log "########## WINGET UPGRADE PROCESS FINISHED FOR APPLICATION ID '$($App.Id)' ##########" "Gray"
#Notify installation #Notify installation
if ($FailedToUpgrade -eq $false){ if ($FailedToUpgrade -eq $false) {
#Send success updated app notification #Send success updated app notification
Write-Log "$($app.Name) updated to $($app.AvailableVersion) !" "Green" Write-Log "$($app.Name) updated to $($app.AvailableVersion) !" "Green"

View File

@ -10,7 +10,7 @@ function Update-WAU {
Start-NotifTask $Title $Message $MessageType $Balise Start-NotifTask $Title $Message $MessageType $Balise
#Run WAU update #Run WAU update
try{ try {
#Force to create a zip file #Force to create a zip file
$ZipFile = "$WorkingDir\WAU_update.zip" $ZipFile = "$WorkingDir\WAU_update.zip"
@ -29,7 +29,7 @@ function Update-WAU {
#Update scritps #Update scritps
Write-Log "Updating WAU" "Yellow" Write-Log "Updating WAU" "Yellow"
$TempPath = (Resolve-Path "$location\*\Winget-AutoUpdate\")[0].Path $TempPath = (Resolve-Path "$location\*\Winget-AutoUpdate\")[0].Path
if ($TempPath){ if ($TempPath) {
Copy-Item -Path "$TempPath\*" -Destination "$WorkingDir\" -Exclude "icons" -Recurse -Force Copy-Item -Path "$TempPath\*" -Destination "$WorkingDir\" -Exclude "icons" -Recurse -Force
} }
@ -62,7 +62,7 @@ function Update-WAU {
} }
catch{ catch {
#Send Error Notif #Send Error Notif
$Title = $NotifLocale.local.outputs.output[4].title -f "Winget-AutoUpdate" $Title = $NotifLocale.local.outputs.output[4].title -f "Winget-AutoUpdate"

View File

@ -2,7 +2,9 @@
#get xml notif config #get xml notif config
[xml]$NotifConf = Get-Content "$env:ProgramData\Winget-AutoUpdate\config\notif.xml" -Encoding UTF8 -ErrorAction SilentlyContinue [xml]$NotifConf = Get-Content "$env:ProgramData\Winget-AutoUpdate\config\notif.xml" -Encoding UTF8 -ErrorAction SilentlyContinue
if (!($NotifConf)) {break} if (!($NotifConf)) {
break
}
#Load Assemblies #Load Assemblies
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null [Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null

View File

@ -3,7 +3,7 @@
#Get Working Dir #Get Working Dir
$Script:WorkingDir = $PSScriptRoot $Script:WorkingDir = $PSScriptRoot
#Get Functions #Get Functions
Get-ChildItem "$WorkingDir\functions" | ForEach-Object {. $_.FullName} Get-ChildItem "$WorkingDir\functions" | ForEach-Object { . $_.FullName }
<# MAIN #> <# MAIN #>
@ -15,7 +15,7 @@ Start-Init
$Script:WAUConfig = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" $Script:WAUConfig = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate"
#Run post update actions if necessary #Run post update actions if necessary
if (!($WAUConfig.WAU_PostUpdateActions -eq 0)){ if (!($WAUConfig.WAU_PostUpdateActions -eq 0)) {
Invoke-PostUpdateActions Invoke-PostUpdateActions
} }
@ -29,42 +29,42 @@ if ([System.Security.Principal.WindowsIdentity]::GetCurrent().IsSystem) {
Get-NotifLocale Get-NotifLocale
#Check network connectivity #Check network connectivity
if (Test-Network){ if (Test-Network) {
#Check if Winget is installed and get Winget cmd #Check if Winget is installed and get Winget cmd
$TestWinget = Get-WingetCmd $TestWinget = Get-WingetCmd
if ($TestWinget){ if ($TestWinget) {
#Get Current Version #Get Current Version
$WAUCurrentVersion = $WAUConfig.DisplayVersion $WAUCurrentVersion = $WAUConfig.DisplayVersion
Write-Log "WAU current version: $WAUCurrentVersion" Write-Log "WAU current version: $WAUCurrentVersion"
#Check if WAU update feature is enabled or not #Check if WAU update feature is enabled or not
$WAUDisableAutoUpdate = $WAUConfig.WAU_DisableAutoUpdate $WAUDisableAutoUpdate = $WAUConfig.WAU_DisableAutoUpdate
#If yes then check WAU update #If yes then check WAU update
if ($WAUDisableAutoUpdate -eq 1){ if ($WAUDisableAutoUpdate -eq 1) {
Write-Log "WAU AutoUpdate is Disabled." "Grey" Write-Log "WAU AutoUpdate is Disabled." "Grey"
} }
else{ else {
Write-Log "WAU AutoUpdate is Enabled." "Green" Write-Log "WAU AutoUpdate is Enabled." "Green"
#Get Available Version #Get Available Version
$WAUAvailableVersion = Get-WAUAvailableVersion $WAUAvailableVersion = Get-WAUAvailableVersion
#Compare #Compare
if ([version]$WAUAvailableVersion -gt [version]$WAUCurrentVersion){ if ([version]$WAUAvailableVersion -gt [version]$WAUCurrentVersion) {
#If new version is available, update it #If new version is available, update it
Write-Log "WAU Available version: $WAUAvailableVersion" "Yellow" Write-Log "WAU Available version: $WAUAvailableVersion" "Yellow"
Update-WAU Update-WAU
} }
else{ else {
Write-Log "WAU is up to date." "Green" Write-Log "WAU is up to date." "Green"
} }
} }
#Get White or Black list #Get White or Black list
if ($WAUConfig.WAU_UseWhiteList -eq 1){ if ($WAUConfig.WAU_UseWhiteList -eq 1) {
Write-Log "WAU uses White List config" Write-Log "WAU uses White List config"
$toUpdate = Get-IncludedApps $toUpdate = Get-IncludedApps
$UseWhiteList = $true $UseWhiteList = $true
} }
else{ else {
Write-Log "WAU uses Black List config" Write-Log "WAU uses Black List config"
$toSkip = Get-ExcludedApps $toSkip = Get-ExcludedApps
} }
@ -73,7 +73,7 @@ if (Test-Network){
$outdated = Get-WingetOutdatedApps $outdated = Get-WingetOutdatedApps
#Log list of app to update #Log list of app to update
foreach ($app in $outdated){ foreach ($app in $outdated) {
#List available updates #List available updates
$Log = "-> Available update : $($app.Name). Current version : $($app.Version). Available version : $($app.AvailableVersion)." $Log = "-> Available update : $($app.Name). Current version : $($app.Version). Available version : $($app.AvailableVersion)."
$Log | Write-host $Log | Write-host
@ -84,44 +84,44 @@ if (Test-Network){
$Script:InstallOK = 0 $Script:InstallOK = 0
#If White List #If White List
if ($UseWhiteList){ if ($UseWhiteList) {
#For each app, notify and update #For each app, notify and update
foreach ($app in $outdated){ foreach ($app in $outdated) {
if (($toUpdate -contains $app.Id) -and $($app.Version) -ne "Unknown"){ if (($toUpdate -contains $app.Id) -and $($app.Version) -ne "Unknown") {
Update-App $app Update-App $app
} }
#if current app version is unknown #if current app version is unknown
elseif($($app.Version) -eq "Unknown"){ elseif ($($app.Version) -eq "Unknown") {
Write-Log "$($app.Name) : Skipped upgrade because current version is 'Unknown'" "Gray" Write-Log "$($app.Name) : Skipped upgrade because current version is 'Unknown'" "Gray"
} }
#if app is in "excluded list" #if app is in "excluded list"
else{ else {
Write-Log "$($app.Name) : Skipped upgrade because it is not in the included app list" "Gray" Write-Log "$($app.Name) : Skipped upgrade because it is not in the included app list" "Gray"
} }
} }
} }
#If Black List or default #If Black List or default
else{ else {
#For each app, notify and update #For each app, notify and update
foreach ($app in $outdated){ foreach ($app in $outdated) {
if (-not ($toSkip -contains $app.Id) -and $($app.Version) -ne "Unknown"){ if (-not ($toSkip -contains $app.Id) -and $($app.Version) -ne "Unknown") {
Update-App $app Update-App $app
} }
#if current app version is unknown #if current app version is unknown
elseif($($app.Version) -eq "Unknown"){ elseif ($($app.Version) -eq "Unknown") {
Write-Log "$($app.Name) : Skipped upgrade because current version is 'Unknown'" "Gray" Write-Log "$($app.Name) : Skipped upgrade because current version is 'Unknown'" "Gray"
} }
#if app is in "excluded list" #if app is in "excluded list"
else{ else {
Write-Log "$($app.Name) : Skipped upgrade because it is in the excluded app list" "Gray" Write-Log "$($app.Name) : Skipped upgrade because it is in the excluded app list" "Gray"
} }
} }
} }
if ($InstallOK -gt 0){ if ($InstallOK -gt 0) {
Write-Log "$InstallOK apps updated ! No more update." "Green" Write-Log "$InstallOK apps updated ! No more update." "Green"
} }
if ($InstallOK -eq 0){ if ($InstallOK -eq 0) {
Write-Log "No new update." "Green" Write-Log "No new update." "Green"
} }
} }