From 29f4ef38128157169a2327fdba3612900d3e1925 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Thu, 2 Feb 2023 18:42:00 +0100 Subject: [PATCH 001/131] v1.16.1 --- Winget-AutoUpdate-Install.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Winget-AutoUpdate-Install.ps1 b/Winget-AutoUpdate-Install.ps1 index 7ce2bd5..f4b1087 100644 --- a/Winget-AutoUpdate-Install.ps1 +++ b/Winget-AutoUpdate-Install.ps1 @@ -113,7 +113,7 @@ param( <# APP INFO #> -$WAUVersion = "1.15.3" +$WAUVersion = "1.16.1" <# FUNCTIONS #> From e4bddddab52cab4bafb30d6a64d573a897202615 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Fri, 3 Feb 2023 00:48:38 +0100 Subject: [PATCH 002/131] A few Functions more --- Winget-AutoUpdate/mods/_AppID-template.ps1 | 46 +++++++++++++++------- Winget-AutoUpdate/mods/_Mods-Functions.ps1 | 35 +++++++++++----- 2 files changed, 56 insertions(+), 25 deletions(-) diff --git a/Winget-AutoUpdate/mods/_AppID-template.ps1 b/Winget-AutoUpdate/mods/_AppID-template.ps1 index b1344cf..7a9aae3 100644 --- a/Winget-AutoUpdate/mods/_AppID-template.ps1 +++ b/Winget-AutoUpdate/mods/_AppID-template.ps1 @@ -13,9 +13,18 @@ $Proc = @("") #Beginning of Process Name to Wait for to End - optional wildcard (*) after, without .exe, multiple: "proc1","proc2" $Wait = @("") +#Install App from Winget Repo, multiple: "appID1","appID2". Example: +#$WingetIDInst = @("Microsoft.PowerToys") +$WingetIDInst = @("") + +#WingetID to uninstall in default manifest mode (silent if supported) +#Multiple: "ID1","ID2". Example: +#$WingetIDUninst = @("Microsoft.PowerToys") +$WingetIDUninst = @("") + #Beginning of App Name string to Silently Uninstall (MSI/NSIS/INNO/EXE with defined silent uninstall in registry) #Multiple: "app1*","app2*", required wildcard (*) after; search is done with "-like"! -$App = @("") +$AppUninst = @("") #Beginning of Desktop Link Name to Remove - optional wildcard (*) after, without .lnk, multiple: "lnk1","lnk2" $Lnk = @("") @@ -37,18 +46,23 @@ $AddType = "" $DelKey = "" $DelValue = "" -#Remove file/directory, multiple: "file1","file2" +#Remove file/directory, multiple: "file1","file2" Example: +#$DelFile = @("${env:ProgramFiles}\PowerToys\PowerToys.Update.exe") $DelFile = @("") -#Copy file/directory -#Example: +#Rename file/directory. Example: +#$RenFile = "${env:ProgramFiles}\PowerToys\PowerToys.Update.exe" +#$NewName = "PowerToys.Update.org" +$RenFile = "" +$NewName = "" + +#Copy file/directory. Example: #$CopyFile = "C:\Logfiles" #$CopyTo = "C:\Drawings\Logs" $CopyFile = "" $CopyTo = "" -#Find/Replace text in file -#Example: +#Find/Replace text in file. Example: #$File = "C:\dummy.txt" #$FindText = 'brown fox' #$ReplaceText = 'white fox' @@ -59,10 +73,6 @@ $ReplaceText = '' #Grant "Modify" for directory/file to "Authenticated Users" - multiple: "dir1","dir2" $GrantPath = @("") -#Install App from Winget Repo, multiple: "appID1","appID2". Example: -#$AppID = @("Microsoft.PowerToys") -$AppID = @("") - #App to Run (as current logged-on user) $RunUser = "" $User = $True @@ -80,8 +90,14 @@ if ($Proc) { if ($Wait) { Wait-ModsProc $Wait } -if ($App) { - Uninstall-ModsApp $App +if ($WingetIDInst) { + Install-WingetID $WingetIDInst +} +if ($WingetIDUninst) { + Uninstall-WingetID $WingetIDUninst +} +if ($AppUninst) { + Uninstall-ModsApp $AppUninst } if ($Lnk) { Remove-ModsLnk $Lnk @@ -95,6 +111,9 @@ if ($DelKey) { if ($DelFile) { Remove-ModsFile $DelFile } +if ($RenFile -and $NewName) { + Rename-ModsFile $RenFile $NewName +} if ($CopyFile -and $CopyTo) { Copy-ModsFile $CopyFile $CopyTo } @@ -104,9 +123,6 @@ if ($File -and $FindText -and $ReplaceText) { if ($GrantPath) { Grant-ModsPath $GrantPath } -if ($AppID) { - Install-ModsApp $AppID -} if ($RunUser) { Invoke-ModsApp $RunUser "" "" $User } diff --git a/Winget-AutoUpdate/mods/_Mods-Functions.ps1 b/Winget-AutoUpdate/mods/_Mods-Functions.ps1 index 054e331..2f6ee3e 100644 --- a/Winget-AutoUpdate/mods/_Mods-Functions.ps1 +++ b/Winget-AutoUpdate/mods/_Mods-Functions.ps1 @@ -35,8 +35,24 @@ function Wait-ModsProc ($Wait) { Return } -function Uninstall-ModsApp ($App) { - foreach ($app in $App) +function Install-WingetID ($WingetIDInst) { + foreach ($app in $WingetIDInst) + { + & $Winget install --id $app --accept-package-agreements --accept-source-agreements -h + } + Return +} + +function Uninstall-WingetID ($WingetIDUninst) { + foreach ($app in $WingetIDUninst) + { + & $Winget uninstall --id $app -e --accept-source-agreements -h + } + Return +} + +function Uninstall-ModsApp ($AppUninst) { + foreach ($app in $AppUninst) { $InstalledSoftware = Get-ChildItem "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall" foreach ($obj in $InstalledSoftware){ @@ -196,6 +212,13 @@ function Remove-ModsFile ($DelFile) { Return } +function Rename-ModsFile ($RenFile, $NewName) { + if (Test-Path "$RenFile") { + Rename-Item -Path $RenFile -NewName $NewName -Force -ErrorAction SilentlyContinue | Out-Null + } + Return +} + function Copy-ModsFile ($CopyFile, $CopyTo) { if (Test-Path "$CopyFile") { Copy-Item -Path $CopyFile -Destination $CopyTo -Recurse -Force -ErrorAction SilentlyContinue | Out-Null @@ -229,11 +252,3 @@ function Grant-ModsPath ($GrantPath) { } Return } - -function Install-ModsApp ($AppID) { - foreach ($app in $AppID) - { - & $Winget install --id $app --accept-package-agreements --accept-source-agreements -h - } - Return -} From 89f7040936177cb5d3c66b601d1e15a95853e64e Mon Sep 17 00:00:00 2001 From: Brightdawn Date: Fri, 3 Feb 2023 16:49:56 +0100 Subject: [PATCH 003/131] Update de.xml Closing Tag missing on Line 52 --- Winget-AutoUpdate/locale/de.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/Winget-AutoUpdate/locale/de.xml b/Winget-AutoUpdate/locale/de.xml index bb95779..1fbeb63 100644 --- a/Winget-AutoUpdate/locale/de.xml +++ b/Winget-AutoUpdate/locale/de.xml @@ -49,6 +49,7 @@ Die manuelle suche nach Updates wurde abgeschlossen. + See changelog From 013e66ebdc3b9079ce1bbfdc8ee40e17afdf1f02 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sat, 4 Feb 2023 01:08:38 +0100 Subject: [PATCH 004/131] Corrected and Safe --- README.md | 3 + Winget-AutoUpdate-Install.ps1 | 13 +- Winget-AutoUpdate/Winget-Upgrade.ps1 | 112 +++++++++--------- .../functions/Get-WingetOutdatedApps.ps1 | 2 +- .../functions/Invoke-PostUpdateActions.ps1 | 12 ++ 5 files changed, 85 insertions(+), 57 deletions(-) diff --git a/README.md b/README.md index 39c476a..2e7547c 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,9 @@ Thanks to [Weatherlights](https://github.com/Weatherlights) in [#256 (reply in t **-ModsPath** Get Mods from external Path (**URL/UNC/Local**) - download/copy to `mods` in Winget-AutoUpdate installation location if external mods are newer. +Security: +If -ModsPath is used during installation WAU assumes it's an enterprise environment and adds a **Deny rule** to the file rights for the directory `mods` for **Local Users** (SID: S-1-5-32-545) making it impossible to implement own scripts that can be executed in **SYSTEM** context. + For **URL**: This requires a site directory with **Directory Listing Enabled** and no index page overriding the listing of files (or an index page with href listing of all the **Mods** to be downloaded): ```
    diff --git a/Winget-AutoUpdate-Install.ps1 b/Winget-AutoUpdate-Install.ps1 index f4b1087..ffa46be 100644 --- a/Winget-AutoUpdate-Install.ps1 +++ b/Winget-AutoUpdate-Install.ps1 @@ -367,7 +367,7 @@ function Install-WingetAutoUpdate { New-ItemProperty $regPath -Name WAU_BypassListForUsers -Value 1 -PropertyType DWord -Force | Out-Null } - #Set ACL for users on logfile + #Set ACL for Authenticated Users on logfile $LogFile = "$WingetUpdatePath\logs\updates.log" if (test-path $LogFile) { $NewAcl = Get-Acl -Path $LogFile @@ -380,6 +380,17 @@ function Install-WingetAutoUpdate { Set-Acl -Path $LogFile -AclObject $NewAcl } + #Most likely an enterprise with central mods, not a home user + if ($ModsPath) { + # Set ReadOnly on Mods Directory for Local Users - Security risk if not done (they could create a script of their own - System Context)! + $directory = Get-Item -Path "$WingetUpdatePath\mods" + $acl = Get-Acl -Path $directory.FullName + $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-32-545") + $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "Write", "Deny") + $acl.SetAccessRule($rule) + Set-Acl -Path $directory.FullName -AclObject $acl + } + #Create Shortcuts if ($StartMenuShortcut) { if (!(Test-Path "${env:ProgramData}\Microsoft\Windows\Start Menu\Programs\Winget-AutoUpdate (WAU)")) { diff --git a/Winget-AutoUpdate/Winget-Upgrade.ps1 b/Winget-AutoUpdate/Winget-Upgrade.ps1 index 55a2e24..febaccc 100644 --- a/Winget-AutoUpdate/Winget-Upgrade.ps1 +++ b/Winget-AutoUpdate/Winget-Upgrade.ps1 @@ -203,70 +203,72 @@ if (Test-Network) { Write-Log "Checking application updates on Winget Repository..." "yellow" $outdated = Get-WingetOutdatedApps - #If something is wrong with the winget source, exit - if ($outdated -like "Problem:*") { - Write-Log "Critical: An error occured, exiting..." "red" - Write-Log "$outdated" "red" - New-Item "$WorkingDir\logs\error.txt" -Value "$outdated" -Force - Exit 1 + #If something unusual happened + if ($outdated -like "An unusual*") { + Write-Log "$outdated" "cyan" + $outdated = $False } - #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 - } - - #Count good update installations - $Script:InstallOK = 0 - - #Trick under user context when -BypassListForUsers is used - if ($IsSystem -eq $false -and $WAUConfig.WAU_BypassListForUsers -eq $true) { - Write-Log "Bypass system list in user context is Enabled." - $UseWhiteList = $false - $toSkip = $null - } - - #If White List - if ($UseWhiteList) { - #For each app, notify and update + #Run only if $outdated is populated! + if ($outdated) { + #Log list of app to update foreach ($app in $outdated) { - if (($toUpdate -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 not in the included app list" "Gray" + #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 + } + + #Count good update installations + $Script:InstallOK = 0 + + #Trick under user context when -BypassListForUsers is used + if ($IsSystem -eq $false -and $WAUConfig.WAU_BypassListForUsers -eq $true) { + Write-Log "Bypass system list in user context is Enabled." + $UseWhiteList = $false + $toSkip = $null + } + + #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 + } + #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" + } } } - } - #If Black List or default - 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" + #If Black List or default + 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" + } } } + + if ($InstallOK -gt 0) { + Write-Log "$InstallOK apps updated ! No more update." "Green" + } } - if ($InstallOK -gt 0) { - Write-Log "$InstallOK apps updated ! No more update." "Green" - } if ($InstallOK -eq 0) { Write-Log "No new update." "Green" } diff --git a/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 b/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 index ae6aa50..53cc0a7 100644 --- a/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 +++ b/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 @@ -13,7 +13,7 @@ function Get-WingetOutdatedApps { #Start Convertion of winget format to an array. Check if "-----" exists (Winget Error Handling) if (!($upgradeResult -match "-----")) { - return "Problem:`n$upgradeResult" + return "An unusual thing happened (maybe all apps are upgraded):`n$upgradeResult" } #Split winget output to lines diff --git a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 index e9eeb5d..ec614d1 100644 --- a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 +++ b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 @@ -53,6 +53,18 @@ function Invoke-PostUpdateActions { Write-Log "-> MaxLogFiles/MaxLogSize setting was missing. Fixed with 3/1048576 (in bytes, default is 1048576 = 1 MB)." } + #Most likely an enterprise with central mods, not a home user + $ModsPath = Get-ItemProperty $regPath -Name WAU_ModsPath -ErrorAction SilentlyContinue + if ($ModsPath) { + # Set ReadOnly on Mods Directory for Local Users - Security risk if not done (they could create a script of their own - System Context)! + $directory = Get-Item -Path "$WingetUpdatePath\mods" + $acl = Get-Acl -Path $directory.FullName + $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-32-545") + $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "Write", "Deny") + $acl.SetAccessRule($rule) + Set-Acl -Path $directory.FullName -AclObject $acl + } + #Convert about.xml if exists (previous WAU versions) to reg $WAUAboutPath = "$WorkingDir\config\about.xml" if (test-path $WAUAboutPath) { From 973b578e2e0807b69d07d9dc4a87c1e29bdeb8c2 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sat, 4 Feb 2023 04:17:35 +0100 Subject: [PATCH 005/131] Done --- README.md | 3 -- Winget-AutoUpdate-Install.ps1 | 44 ++++++++++++++---- .../functions/Invoke-PostUpdateActions.ps1 | 46 ++++++++++++++----- 3 files changed, 69 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 2e7547c..39c476a 100644 --- a/README.md +++ b/README.md @@ -103,9 +103,6 @@ Thanks to [Weatherlights](https://github.com/Weatherlights) in [#256 (reply in t **-ModsPath** Get Mods from external Path (**URL/UNC/Local**) - download/copy to `mods` in Winget-AutoUpdate installation location if external mods are newer. -Security: -If -ModsPath is used during installation WAU assumes it's an enterprise environment and adds a **Deny rule** to the file rights for the directory `mods` for **Local Users** (SID: S-1-5-32-545) making it impossible to implement own scripts that can be executed in **SYSTEM** context. - For **URL**: This requires a site directory with **Directory Listing Enabled** and no index page overriding the listing of files (or an index page with href listing of all the **Mods** to be downloaded): ```
      diff --git a/Winget-AutoUpdate-Install.ps1 b/Winget-AutoUpdate-Install.ps1 index ffa46be..f0a24ef 100644 --- a/Winget-AutoUpdate-Install.ps1 +++ b/Winget-AutoUpdate-Install.ps1 @@ -380,16 +380,40 @@ function Install-WingetAutoUpdate { Set-Acl -Path $LogFile -AclObject $NewAcl } - #Most likely an enterprise with central mods, not a home user - if ($ModsPath) { - # Set ReadOnly on Mods Directory for Local Users - Security risk if not done (they could create a script of their own - System Context)! - $directory = Get-Item -Path "$WingetUpdatePath\mods" - $acl = Get-Acl -Path $directory.FullName - $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-32-545") - $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "Write", "Deny") - $acl.SetAccessRule($rule) - Set-Acl -Path $directory.FullName -AclObject $acl - } + #Security: Mods directory must be protected (Users could create scripts of their own - then they're run in System Context)! + $directory = Get-Item -Path "$WingetUpdatePath\mods" + $acl = Get-Acl -Path $directory.FullName + #Disable inheritance + $acl.SetAccessRuleProtection($True, $True) + # Remove any existing rules + $acl.Access | ForEach-Object { $acl.RemoveAccessRule($_) } + #SYSTEM Full - S-1-5-18 + $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-18") + $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID,"FullControl","ContainerInherit,ObjectInherit","None","Allow") + $acl.SetAccessRule($rule) + # Save the updated ACL + Set-Acl -Path $directory.FullName -AclObject $acl | Out-Null + + #Administrators Full - S-1-5-32-544 + $acl = Get-Acl -Path $directory.FullName + $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-32-544") + $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID,"FullControl","ContainerInherit,ObjectInherit","None","Allow") + $acl.SetAccessRule($rule) + Set-Acl -Path $directory.FullName -AclObject $acl + + #Local Users ReadAndExecute - S-1-5-32-545 S-1-5-11 + $acl = Get-Acl -Path $directory.FullName + $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-32-545") + $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "ReadAndExecute","ContainerInherit,ObjectInherit","None","Allow") + $acl.SetAccessRule($rule) + Set-Acl -Path $directory.FullName -AclObject $acl + + #Authenticated Users ReadAndExecute - S-1-5-11 + $acl = Get-Acl -Path $directory.FullName + $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-11") + $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "ReadAndExecute","ContainerInherit,ObjectInherit","None","Allow") + $acl.SetAccessRule($rule) + Set-Acl -Path $directory.FullName -AclObject $acl #Create Shortcuts if ($StartMenuShortcut) { diff --git a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 index ec614d1..bd6a608 100644 --- a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 +++ b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 @@ -53,17 +53,41 @@ function Invoke-PostUpdateActions { Write-Log "-> MaxLogFiles/MaxLogSize setting was missing. Fixed with 3/1048576 (in bytes, default is 1048576 = 1 MB)." } - #Most likely an enterprise with central mods, not a home user - $ModsPath = Get-ItemProperty $regPath -Name WAU_ModsPath -ErrorAction SilentlyContinue - if ($ModsPath) { - # Set ReadOnly on Mods Directory for Local Users - Security risk if not done (they could create a script of their own - System Context)! - $directory = Get-Item -Path "$WingetUpdatePath\mods" - $acl = Get-Acl -Path $directory.FullName - $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-32-545") - $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "Write", "Deny") - $acl.SetAccessRule($rule) - Set-Acl -Path $directory.FullName -AclObject $acl - } + #Security: Mods directory must be protected (Users could create scripts of their own - then they're run in System Context)! + $WingetUpdatePath = Get-ItemProperty $regPath -Name InstallLocation -ErrorAction SilentlyContinue + $directory = Get-Item -Path "$WingetUpdatePath\mods" + $acl = Get-Acl -Path $directory.FullName + #Disable inheritance + $acl.SetAccessRuleProtection($True, $True) + # Remove any existing rules + $acl.Access | ForEach-Object { $acl.RemoveAccessRule($_) } + #SYSTEM Full - S-1-5-18 + $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-18") + $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID,"FullControl","ContainerInherit,ObjectInherit","None","Allow") + $acl.SetAccessRule($rule) + # Save the updated ACL + Set-Acl -Path $directory.FullName -AclObject $acl | Out-Null + + #Administrators Full - S-1-5-32-544 + $acl = Get-Acl -Path $directory.FullName + $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-32-544") + $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID,"FullControl","ContainerInherit,ObjectInherit","None","Allow") + $acl.SetAccessRule($rule) + Set-Acl -Path $directory.FullName -AclObject $acl + + #Local Users ReadAndExecute - S-1-5-32-545 S-1-5-11 + $acl = Get-Acl -Path $directory.FullName + $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-32-545") + $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "ReadAndExecute","ContainerInherit,ObjectInherit","None","Allow") + $acl.SetAccessRule($rule) + Set-Acl -Path $directory.FullName -AclObject $acl + + #Authenticated Users ReadAndExecute - S-1-5-11 + $acl = Get-Acl -Path $directory.FullName + $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-11") + $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "ReadAndExecute","ContainerInherit,ObjectInherit","None","Allow") + $acl.SetAccessRule($rule) + Set-Acl -Path $directory.FullName -AclObject $acl #Convert about.xml if exists (previous WAU versions) to reg $WAUAboutPath = "$WorkingDir\config\about.xml" From a1a427ec254d6cc00f18960f9f35c73f267757ee Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sat, 4 Feb 2023 14:06:07 +0100 Subject: [PATCH 006/131] Log - No new update --- Winget-AutoUpdate/Winget-Upgrade.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Winget-AutoUpdate/Winget-Upgrade.ps1 b/Winget-AutoUpdate/Winget-Upgrade.ps1 index febaccc..39e4285 100644 --- a/Winget-AutoUpdate/Winget-Upgrade.ps1 +++ b/Winget-AutoUpdate/Winget-Upgrade.ps1 @@ -269,7 +269,7 @@ if (Test-Network) { } } - if ($InstallOK -eq 0) { + if ($InstallOK -eq 0 -or !$InstallOK) { Write-Log "No new update." "Green" } From 80f61d9b15c90431d4815d966658b157b815f775 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sun, 5 Feb 2023 00:10:32 +0100 Subject: [PATCH 007/131] All done now! --- Winget-AutoUpdate-Install.ps1 | 77 ++++++++++++------- .../functions/Invoke-PostUpdateActions.ps1 | 77 ++++++++++++------- 2 files changed, 96 insertions(+), 58 deletions(-) diff --git a/Winget-AutoUpdate-Install.ps1 b/Winget-AutoUpdate-Install.ps1 index f0a24ef..9e5d3b7 100644 --- a/Winget-AutoUpdate-Install.ps1 +++ b/Winget-AutoUpdate-Install.ps1 @@ -381,40 +381,59 @@ function Install-WingetAutoUpdate { } #Security: Mods directory must be protected (Users could create scripts of their own - then they're run in System Context)! + #Check if Local Users have write rights in Mods directory or not $directory = Get-Item -Path "$WingetUpdatePath\mods" $acl = Get-Acl -Path $directory.FullName - #Disable inheritance - $acl.SetAccessRuleProtection($True, $True) - # Remove any existing rules - $acl.Access | ForEach-Object { $acl.RemoveAccessRule($_) } - #SYSTEM Full - S-1-5-18 - $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-18") - $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID,"FullControl","ContainerInherit,ObjectInherit","None","Allow") - $acl.SetAccessRule($rule) - # Save the updated ACL - Set-Acl -Path $directory.FullName -AclObject $acl | Out-Null - - #Administrators Full - S-1-5-32-544 - $acl = Get-Acl -Path $directory.FullName - $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-32-544") - $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID,"FullControl","ContainerInherit,ObjectInherit","None","Allow") - $acl.SetAccessRule($rule) - Set-Acl -Path $directory.FullName -AclObject $acl - - #Local Users ReadAndExecute - S-1-5-32-545 S-1-5-11 - $acl = Get-Acl -Path $directory.FullName + #Local Users - S-1-5-32-545 $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-32-545") - $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "ReadAndExecute","ContainerInherit,ObjectInherit","None","Allow") - $acl.SetAccessRule($rule) - Set-Acl -Path $directory.FullName -AclObject $acl + #Translate SID to Locale Name + $ntAccount = $userSID.Translate([System.Security.Principal.NTAccount]) + $userName = $ntAccount.Value + $userRights = [System.Security.AccessControl.FileSystemRights]"Write" + + $hasWriteAccess = $False + + foreach ($access in $acl.Access) { + if ($access.IdentityReference.Value -eq $userName -and $access.FileSystemRights -eq $userRights) { + $hasWriteAccess = $True + break + } + } + + if ($hasWriteAccess) { + #Disable inheritance + $acl.SetAccessRuleProtection($True, $True) + # Remove any existing rules + $acl.Access | ForEach-Object { $acl.RemoveAccessRule($_) } + #SYSTEM Full - S-1-5-18 + $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-18") + $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID,"FullControl","ContainerInherit,ObjectInherit","None","Allow") + $acl.SetAccessRule($rule) + # Save the updated ACL + Set-Acl -Path $directory.FullName -AclObject $acl - #Authenticated Users ReadAndExecute - S-1-5-11 - $acl = Get-Acl -Path $directory.FullName - $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-11") - $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "ReadAndExecute","ContainerInherit,ObjectInherit","None","Allow") - $acl.SetAccessRule($rule) - Set-Acl -Path $directory.FullName -AclObject $acl + #Administrators Full - S-1-5-32-544 + $acl = Get-Acl -Path $directory.FullName + $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-32-544") + $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID,"FullControl","ContainerInherit,ObjectInherit","None","Allow") + $acl.SetAccessRule($rule) + Set-Acl -Path $directory.FullName -AclObject $acl + + #Local Users ReadAndExecute - S-1-5-32-545 S-1-5-11 + $acl = Get-Acl -Path $directory.FullName + $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-32-545") + $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "ReadAndExecute","ContainerInherit,ObjectInherit","None","Allow") + $acl.SetAccessRule($rule) + Set-Acl -Path $directory.FullName -AclObject $acl + #Authenticated Users ReadAndExecute - S-1-5-11 + $acl = Get-Acl -Path $directory.FullName + $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-11") + $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "ReadAndExecute","ContainerInherit,ObjectInherit","None","Allow") + $acl.SetAccessRule($rule) + Set-Acl -Path $directory.FullName -AclObject $acl + } + #Create Shortcuts if ($StartMenuShortcut) { if (!(Test-Path "${env:ProgramData}\Microsoft\Windows\Start Menu\Programs\Winget-AutoUpdate (WAU)")) { diff --git a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 index bd6a608..18ba7ca 100644 --- a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 +++ b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 @@ -54,40 +54,59 @@ function Invoke-PostUpdateActions { } #Security: Mods directory must be protected (Users could create scripts of their own - then they're run in System Context)! + #Check if Local Users have write rights in Mods directory or not $WingetUpdatePath = Get-ItemProperty $regPath -Name InstallLocation -ErrorAction SilentlyContinue $directory = Get-Item -Path "$WingetUpdatePath\mods" $acl = Get-Acl -Path $directory.FullName - #Disable inheritance - $acl.SetAccessRuleProtection($True, $True) - # Remove any existing rules - $acl.Access | ForEach-Object { $acl.RemoveAccessRule($_) } - #SYSTEM Full - S-1-5-18 - $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-18") - $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID,"FullControl","ContainerInherit,ObjectInherit","None","Allow") - $acl.SetAccessRule($rule) - # Save the updated ACL - Set-Acl -Path $directory.FullName -AclObject $acl | Out-Null - - #Administrators Full - S-1-5-32-544 - $acl = Get-Acl -Path $directory.FullName - $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-32-544") - $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID,"FullControl","ContainerInherit,ObjectInherit","None","Allow") - $acl.SetAccessRule($rule) - Set-Acl -Path $directory.FullName -AclObject $acl - - #Local Users ReadAndExecute - S-1-5-32-545 S-1-5-11 - $acl = Get-Acl -Path $directory.FullName + #Local Users - S-1-5-32-545 $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-32-545") - $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "ReadAndExecute","ContainerInherit,ObjectInherit","None","Allow") - $acl.SetAccessRule($rule) - Set-Acl -Path $directory.FullName -AclObject $acl + #Translate SID to Locale Name + $ntAccount = $userSID.Translate([System.Security.Principal.NTAccount]) + $userName = $ntAccount.Value + $userRights = [System.Security.AccessControl.FileSystemRights]"Write" + + $hasWriteAccess = $False + + foreach ($access in $acl.Access) { + if ($access.IdentityReference.Value -eq $userName -and $access.FileSystemRights -eq $userRights) { + $hasWriteAccess = $True + break + } + } + + if ($hasWriteAccess) { + #Disable inheritance + $acl.SetAccessRuleProtection($True, $True) + # Remove any existing rules + $acl.Access | ForEach-Object { $acl.RemoveAccessRule($_) } + #SYSTEM Full - S-1-5-18 + $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-18") + $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID,"FullControl","ContainerInherit,ObjectInherit","None","Allow") + $acl.SetAccessRule($rule) + # Save the updated ACL + Set-Acl -Path $directory.FullName -AclObject $acl - #Authenticated Users ReadAndExecute - S-1-5-11 - $acl = Get-Acl -Path $directory.FullName - $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-11") - $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "ReadAndExecute","ContainerInherit,ObjectInherit","None","Allow") - $acl.SetAccessRule($rule) - Set-Acl -Path $directory.FullName -AclObject $acl + #Administrators Full - S-1-5-32-544 + $acl = Get-Acl -Path $directory.FullName + $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-32-544") + $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID,"FullControl","ContainerInherit,ObjectInherit","None","Allow") + $acl.SetAccessRule($rule) + Set-Acl -Path $directory.FullName -AclObject $acl + + #Local Users ReadAndExecute - S-1-5-32-545 S-1-5-11 + $acl = Get-Acl -Path $directory.FullName + $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-32-545") + $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "ReadAndExecute","ContainerInherit,ObjectInherit","None","Allow") + $acl.SetAccessRule($rule) + Set-Acl -Path $directory.FullName -AclObject $acl + + #Authenticated Users ReadAndExecute - S-1-5-11 + $acl = Get-Acl -Path $directory.FullName + $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-11") + $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "ReadAndExecute","ContainerInherit,ObjectInherit","None","Allow") + $acl.SetAccessRule($rule) + Set-Acl -Path $directory.FullName -AclObject $acl + } #Convert about.xml if exists (previous WAU versions) to reg $WAUAboutPath = "$WorkingDir\config\about.xml" From 499f212df721ba6a2e683110c13f50f76e37a0c7 Mon Sep 17 00:00:00 2001 From: Fabian Seitz Date: Sun, 5 Feb 2023 13:06:24 +0100 Subject: [PATCH 008/131] fix dependabot Github Workflow #264 --- .github/{workflows => }/dependabot.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{workflows => }/dependabot.yml (100%) diff --git a/.github/workflows/dependabot.yml b/.github/dependabot.yml similarity index 100% rename from .github/workflows/dependabot.yml rename to .github/dependabot.yml From f0e63fae0ab0af760c89ca67bcff1199cb4b3005 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 5 Feb 2023 12:07:22 +0000 Subject: [PATCH 009/131] Bump actions/stale from 4 to 7 Bumps [actions/stale](https://github.com/actions/stale) from 4 to 7. - [Release notes](https://github.com/actions/stale/releases) - [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/stale/compare/v4...v7) --- updated-dependencies: - dependency-name: actions/stale dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/CloseInactiveIssues.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CloseInactiveIssues.yml b/.github/workflows/CloseInactiveIssues.yml index 315c9e9..a529a5c 100644 --- a/.github/workflows/CloseInactiveIssues.yml +++ b/.github/workflows/CloseInactiveIssues.yml @@ -10,7 +10,7 @@ jobs: issues: write pull-requests: write steps: - - uses: actions/stale@v4 + - uses: actions/stale@v7 with: days-before-issue-stale: 30 days-before-issue-close: 14 From 2c542cd9d540b61a4865442e881f12a4a3009ffd Mon Sep 17 00:00:00 2001 From: Fabian Seitz Date: Sun, 5 Feb 2023 13:15:53 +0100 Subject: [PATCH 010/131] improve megalinter workflow --- .github/workflows/mega-linter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mega-linter.yml b/.github/workflows/mega-linter.yml index d5d6cc0..16904e2 100644 --- a/.github/workflows/mega-linter.yml +++ b/.github/workflows/mega-linter.yml @@ -49,7 +49,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SPELL_CSPELL_CONFIG_FILE: .github/cspell.json POWERSHELL_POWERSHELL_CONFIG_FILE: .github/.powershell-psscriptanalyzer.psd1 - DISABLE_ERRORS_LINTERS: REPOSITORY_DEVSKIM,SPELL_CSPELL,SPELL_PROSELINT,COPYPASTE_JSCPD,MARKDOWN_MARKDOWN_LINK_CHECK + DISABLE_ERRORS_LINTERS: REPOSITORY_DEVSKIM,REPOSITORY_GIT_DIFF,SPELL_CSPELL,SPELL_PROSELINT,COPYPASTE_JSCPD,MARKDOWN_MARKDOWN_LINK_CHECK FILTER_REGEX_EXCLUDE: (.github/workflows/) # Upload MegaLinter artifacts From d20fddf0975c6dff09567e5ec7661f6cfa342c98 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sun, 5 Feb 2023 15:17:43 +0100 Subject: [PATCH 011/131] Log --- Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 index 18ba7ca..8303eec 100644 --- a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 +++ b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 @@ -106,6 +106,10 @@ function Invoke-PostUpdateActions { $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "ReadAndExecute","ContainerInherit,ObjectInherit","None","Allow") $acl.SetAccessRule($rule) Set-Acl -Path $directory.FullName -AclObject $acl + + #log + Write-Log "-> The mods directory is now secured!." + } #Convert about.xml if exists (previous WAU versions) to reg From 7e04696cc0379d0fb3b470150fd1e07c7f955c34 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Mon, 6 Feb 2023 07:47:06 +0100 Subject: [PATCH 012/131] Function for ModsProtect --- Winget-AutoUpdate-Install.ps1 | 59 +++-------------- .../functions/Invoke-ModsProtect.ps1 | 60 ++++++++++++++++++ .../functions/Invoke-PostUpdateActions.ps1 | 63 +++---------------- 3 files changed, 75 insertions(+), 107 deletions(-) create mode 100644 Winget-AutoUpdate/functions/Invoke-ModsProtect.ps1 diff --git a/Winget-AutoUpdate-Install.ps1 b/Winget-AutoUpdate-Install.ps1 index 9e5d3b7..3ab3a11 100644 --- a/Winget-AutoUpdate-Install.ps1 +++ b/Winget-AutoUpdate-Install.ps1 @@ -380,58 +380,15 @@ function Install-WingetAutoUpdate { Set-Acl -Path $LogFile -AclObject $NewAcl } - #Security: Mods directory must be protected (Users could create scripts of their own - then they're run in System Context)! - #Check if Local Users have write rights in Mods directory or not - $directory = Get-Item -Path "$WingetUpdatePath\mods" - $acl = Get-Acl -Path $directory.FullName - #Local Users - S-1-5-32-545 - $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-32-545") - #Translate SID to Locale Name - $ntAccount = $userSID.Translate([System.Security.Principal.NTAccount]) - $userName = $ntAccount.Value - $userRights = [System.Security.AccessControl.FileSystemRights]"Write" - - $hasWriteAccess = $False - - foreach ($access in $acl.Access) { - if ($access.IdentityReference.Value -eq $userName -and $access.FileSystemRights -eq $userRights) { - $hasWriteAccess = $True - break - } + #Security check + Write-host "`nChecking Mods Directory:" -ForegroundColor Yellow + . "$WingetUpdatePath\functions\Invoke-ModsProtect.ps1" + $Protected = Invoke-ModsProtect "$WingetUpdatePath\mods" + if ($Protected) { + Write-Host "The mods directory is now secured!`n" -ForegroundColor Green } - - if ($hasWriteAccess) { - #Disable inheritance - $acl.SetAccessRuleProtection($True, $True) - # Remove any existing rules - $acl.Access | ForEach-Object { $acl.RemoveAccessRule($_) } - #SYSTEM Full - S-1-5-18 - $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-18") - $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID,"FullControl","ContainerInherit,ObjectInherit","None","Allow") - $acl.SetAccessRule($rule) - # Save the updated ACL - Set-Acl -Path $directory.FullName -AclObject $acl - - #Administrators Full - S-1-5-32-544 - $acl = Get-Acl -Path $directory.FullName - $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-32-544") - $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID,"FullControl","ContainerInherit,ObjectInherit","None","Allow") - $acl.SetAccessRule($rule) - Set-Acl -Path $directory.FullName -AclObject $acl - - #Local Users ReadAndExecute - S-1-5-32-545 S-1-5-11 - $acl = Get-Acl -Path $directory.FullName - $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-32-545") - $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "ReadAndExecute","ContainerInherit,ObjectInherit","None","Allow") - $acl.SetAccessRule($rule) - Set-Acl -Path $directory.FullName -AclObject $acl - - #Authenticated Users ReadAndExecute - S-1-5-11 - $acl = Get-Acl -Path $directory.FullName - $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-11") - $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "ReadAndExecute","ContainerInherit,ObjectInherit","None","Allow") - $acl.SetAccessRule($rule) - Set-Acl -Path $directory.FullName -AclObject $acl + elseif (!$Protected) { + Write-Host "The mods directory was already secured!`n" -ForegroundColor Green } #Create Shortcuts diff --git a/Winget-AutoUpdate/functions/Invoke-ModsProtect.ps1 b/Winget-AutoUpdate/functions/Invoke-ModsProtect.ps1 new file mode 100644 index 0000000..98eff2e --- /dev/null +++ b/Winget-AutoUpdate/functions/Invoke-ModsProtect.ps1 @@ -0,0 +1,60 @@ +#Function to check if Mods Directory is secured. +#Security: Mods directory must be protected (Users could create scripts of their own - then they'll run in System Context)! +#Check if Local Users have write rights in Mods directory or not (and take action if necessary): + +function Invoke-ModsProtect ($ModsPath) { + $directory = Get-Item -Path $ModsPath + $acl = Get-Acl -Path $directory.FullName + #Local Users - S-1-5-32-545 + $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-32-545") + #Translate SID to Locale Name + $ntAccount = $userSID.Translate([System.Security.Principal.NTAccount]) + $userName = $ntAccount.Value + $userRights = [System.Security.AccessControl.FileSystemRights]"Write" + + $hasWriteAccess = $False + + foreach ($access in $acl.Access) { + if ($access.IdentityReference.Value -eq $userName -and $access.FileSystemRights -eq $userRights) { + $hasWriteAccess = $True + break + } + } + + if ($hasWriteAccess) { + #Disable inheritance + $acl.SetAccessRuleProtection($True, $True) + # Remove any existing rules + $acl.Access | ForEach-Object { $acl.RemoveAccessRule($_) } + #SYSTEM Full - S-1-5-18 + $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-18") + $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID,"FullControl","ContainerInherit,ObjectInherit","None","Allow") + $acl.SetAccessRule($rule) + # Save the updated ACL + Set-Acl -Path $directory.FullName -AclObject $acl + + #Administrators Full - S-1-5-32-544 + $acl = Get-Acl -Path $directory.FullName + $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-32-544") + $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID,"FullControl","ContainerInherit,ObjectInherit","None","Allow") + $acl.SetAccessRule($rule) + Set-Acl -Path $directory.FullName -AclObject $acl + + #Local Users ReadAndExecute - S-1-5-32-545 S-1-5-11 + $acl = Get-Acl -Path $directory.FullName + $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-32-545") + $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "ReadAndExecute","ContainerInherit,ObjectInherit","None","Allow") + $acl.SetAccessRule($rule) + Set-Acl -Path $directory.FullName -AclObject $acl + + #Authenticated Users ReadAndExecute - S-1-5-11 + $acl = Get-Acl -Path $directory.FullName + $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-11") + $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "ReadAndExecute","ContainerInherit,ObjectInherit","None","Allow") + $acl.SetAccessRule($rule) + Set-Acl -Path $directory.FullName -AclObject $acl + + return $True + } + return $False +} \ No newline at end of file diff --git a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 index 8303eec..35d2acb 100644 --- a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 +++ b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 @@ -53,63 +53,14 @@ function Invoke-PostUpdateActions { Write-Log "-> MaxLogFiles/MaxLogSize setting was missing. Fixed with 3/1048576 (in bytes, default is 1048576 = 1 MB)." } - #Security: Mods directory must be protected (Users could create scripts of their own - then they're run in System Context)! - #Check if Local Users have write rights in Mods directory or not - $WingetUpdatePath = Get-ItemProperty $regPath -Name InstallLocation -ErrorAction SilentlyContinue - $directory = Get-Item -Path "$WingetUpdatePath\mods" - $acl = Get-Acl -Path $directory.FullName - #Local Users - S-1-5-32-545 - $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-32-545") - #Translate SID to Locale Name - $ntAccount = $userSID.Translate([System.Security.Principal.NTAccount]) - $userName = $ntAccount.Value - $userRights = [System.Security.AccessControl.FileSystemRights]"Write" - - $hasWriteAccess = $False - - foreach ($access in $acl.Access) { - if ($access.IdentityReference.Value -eq $userName -and $access.FileSystemRights -eq $userRights) { - $hasWriteAccess = $True - break - } + #Security check + Write-Log "-> Checking Mods Directory:" "yellow" + $Protected = Invoke-ModsProtect "$($WAUConfig.InstallLocation)\mods" + if ($Protected) { + Write-Log "-> The mods directory is now secured!" "green" } - - if ($hasWriteAccess) { - #Disable inheritance - $acl.SetAccessRuleProtection($True, $True) - # Remove any existing rules - $acl.Access | ForEach-Object { $acl.RemoveAccessRule($_) } - #SYSTEM Full - S-1-5-18 - $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-18") - $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID,"FullControl","ContainerInherit,ObjectInherit","None","Allow") - $acl.SetAccessRule($rule) - # Save the updated ACL - Set-Acl -Path $directory.FullName -AclObject $acl - - #Administrators Full - S-1-5-32-544 - $acl = Get-Acl -Path $directory.FullName - $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-32-544") - $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID,"FullControl","ContainerInherit,ObjectInherit","None","Allow") - $acl.SetAccessRule($rule) - Set-Acl -Path $directory.FullName -AclObject $acl - - #Local Users ReadAndExecute - S-1-5-32-545 S-1-5-11 - $acl = Get-Acl -Path $directory.FullName - $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-32-545") - $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "ReadAndExecute","ContainerInherit,ObjectInherit","None","Allow") - $acl.SetAccessRule($rule) - Set-Acl -Path $directory.FullName -AclObject $acl - - #Authenticated Users ReadAndExecute - S-1-5-11 - $acl = Get-Acl -Path $directory.FullName - $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-11") - $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "ReadAndExecute","ContainerInherit,ObjectInherit","None","Allow") - $acl.SetAccessRule($rule) - Set-Acl -Path $directory.FullName -AclObject $acl - - #log - Write-Log "-> The mods directory is now secured!." - + elseif (!$Protected) { + Write-Log "-> The mods directory was already secured!" "green" } #Convert about.xml if exists (previous WAU versions) to reg From 95abd0f80778e08c4040e910725735707b9f07fb Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Tue, 7 Feb 2023 05:50:18 +0100 Subject: [PATCH 013/131] Set WAU_ModsPath if not set when upgrading online --- Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 index 35d2acb..97a91ae 100644 --- a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 +++ b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 @@ -53,6 +53,15 @@ function Invoke-PostUpdateActions { Write-Log "-> MaxLogFiles/MaxLogSize setting was missing. Fixed with 3/1048576 (in bytes, default is 1048576 = 1 MB)." } + #Set WAU_ModsPath if not set + $ModsPath = Get-ItemProperty $regPath -Name WAU_ModsPath -ErrorAction SilentlyContinue + if (!$ModsPath) { + New-ItemProperty $regPath -Name WAU_ModsPath -Force | Out-Null + + #log + Write-Log "-> ModsPath setting was missing. Fixed with empty string." + } + #Security check Write-Log "-> Checking Mods Directory:" "yellow" $Protected = Invoke-ModsProtect "$($WAUConfig.InstallLocation)\mods" From 2471438c3b524332ec64c413fee2708613cf42e1 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Tue, 7 Feb 2023 06:04:13 +0100 Subject: [PATCH 014/131] ListPath as well... --- Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 index 97a91ae..de89e3c 100644 --- a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 +++ b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 @@ -53,6 +53,15 @@ function Invoke-PostUpdateActions { Write-Log "-> MaxLogFiles/MaxLogSize setting was missing. Fixed with 3/1048576 (in bytes, default is 1048576 = 1 MB)." } + #Set WAU_ListPath if not set + $ListPath = Get-ItemProperty $regPath -Name WAU_ListPath -ErrorAction SilentlyContinue + if (!$ListPath) { + New-ItemProperty $regPath -Name WAU_ListPath -Force | Out-Null + + #log + Write-Log "-> ListPath setting was missing. Fixed with empty string." + } + #Set WAU_ModsPath if not set $ModsPath = Get-ItemProperty $regPath -Name WAU_ModsPath -ErrorAction SilentlyContinue if (!$ModsPath) { From c505773f8cf1086664c9094c919ef6c16ba5e14a Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Tue, 7 Feb 2023 20:06:54 +0100 Subject: [PATCH 015/131] A bit of error handling in ModsProtect --- Winget-AutoUpdate-Install.ps1 | 7 +- .../functions/Invoke-ModsProtect.ps1 | 107 +++++++++--------- .../functions/Invoke-PostUpdateActions.ps1 | 7 +- 3 files changed, 66 insertions(+), 55 deletions(-) diff --git a/Winget-AutoUpdate-Install.ps1 b/Winget-AutoUpdate-Install.ps1 index 3ab3a11..b836d5a 100644 --- a/Winget-AutoUpdate-Install.ps1 +++ b/Winget-AutoUpdate-Install.ps1 @@ -384,12 +384,15 @@ function Install-WingetAutoUpdate { Write-host "`nChecking Mods Directory:" -ForegroundColor Yellow . "$WingetUpdatePath\functions\Invoke-ModsProtect.ps1" $Protected = Invoke-ModsProtect "$WingetUpdatePath\mods" - if ($Protected) { + if ($Protected -eq $True) { Write-Host "The mods directory is now secured!`n" -ForegroundColor Green } - elseif (!$Protected) { + elseif ($Protected -eq $False) { Write-Host "The mods directory was already secured!`n" -ForegroundColor Green } + else { + Write-Host "Error: The mods directory couldn't be verified as secured!`n" -ForegroundColor Red + } #Create Shortcuts if ($StartMenuShortcut) { diff --git a/Winget-AutoUpdate/functions/Invoke-ModsProtect.ps1 b/Winget-AutoUpdate/functions/Invoke-ModsProtect.ps1 index 98eff2e..b800571 100644 --- a/Winget-AutoUpdate/functions/Invoke-ModsProtect.ps1 +++ b/Winget-AutoUpdate/functions/Invoke-ModsProtect.ps1 @@ -3,58 +3,63 @@ #Check if Local Users have write rights in Mods directory or not (and take action if necessary): function Invoke-ModsProtect ($ModsPath) { - $directory = Get-Item -Path $ModsPath - $acl = Get-Acl -Path $directory.FullName - #Local Users - S-1-5-32-545 - $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-32-545") - #Translate SID to Locale Name - $ntAccount = $userSID.Translate([System.Security.Principal.NTAccount]) - $userName = $ntAccount.Value - $userRights = [System.Security.AccessControl.FileSystemRights]"Write" - - $hasWriteAccess = $False - - foreach ($access in $acl.Access) { - if ($access.IdentityReference.Value -eq $userName -and $access.FileSystemRights -eq $userRights) { - $hasWriteAccess = $True - break - } - } - - if ($hasWriteAccess) { - #Disable inheritance - $acl.SetAccessRuleProtection($True, $True) - # Remove any existing rules - $acl.Access | ForEach-Object { $acl.RemoveAccessRule($_) } - #SYSTEM Full - S-1-5-18 - $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-18") - $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID,"FullControl","ContainerInherit,ObjectInherit","None","Allow") - $acl.SetAccessRule($rule) - # Save the updated ACL - Set-Acl -Path $directory.FullName -AclObject $acl - - #Administrators Full - S-1-5-32-544 - $acl = Get-Acl -Path $directory.FullName - $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-32-544") - $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID,"FullControl","ContainerInherit,ObjectInherit","None","Allow") - $acl.SetAccessRule($rule) - Set-Acl -Path $directory.FullName -AclObject $acl - - #Local Users ReadAndExecute - S-1-5-32-545 S-1-5-11 + try { + $directory = Get-Item -Path $ModsPath -ErrorAction SilentlyContinue $acl = Get-Acl -Path $directory.FullName + #Local Users - S-1-5-32-545 $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-32-545") - $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "ReadAndExecute","ContainerInherit,ObjectInherit","None","Allow") - $acl.SetAccessRule($rule) - Set-Acl -Path $directory.FullName -AclObject $acl - - #Authenticated Users ReadAndExecute - S-1-5-11 - $acl = Get-Acl -Path $directory.FullName - $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-11") - $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "ReadAndExecute","ContainerInherit,ObjectInherit","None","Allow") - $acl.SetAccessRule($rule) - Set-Acl -Path $directory.FullName -AclObject $acl - - return $True + #Translate SID to Locale Name + $ntAccount = $userSID.Translate([System.Security.Principal.NTAccount]) + $userName = $ntAccount.Value + $userRights = [System.Security.AccessControl.FileSystemRights]"Write" + + $hasWriteAccess = $False + + foreach ($access in $acl.Access) { + if ($access.IdentityReference.Value -eq $userName -and $access.FileSystemRights -eq $userRights) { + $hasWriteAccess = $True + break + } + } + + if ($hasWriteAccess) { + #Disable inheritance + $acl.SetAccessRuleProtection($True, $True) + # Remove any existing rules + $acl.Access | ForEach-Object { $acl.RemoveAccessRule($_) } + #SYSTEM Full - S-1-5-18 + $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-18") + $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID,"FullControl","ContainerInherit,ObjectInherit","None","Allow") + $acl.SetAccessRule($rule) + # Save the updated ACL + Set-Acl -Path $directory.FullName -AclObject $acl + + #Administrators Full - S-1-5-32-544 + $acl = Get-Acl -Path $directory.FullName + $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-32-544") + $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID,"FullControl","ContainerInherit,ObjectInherit","None","Allow") + $acl.SetAccessRule($rule) + Set-Acl -Path $directory.FullName -AclObject $acl + + #Local Users ReadAndExecute - S-1-5-32-545 S-1-5-11 + $acl = Get-Acl -Path $directory.FullName + $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-32-545") + $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "ReadAndExecute","ContainerInherit,ObjectInherit","None","Allow") + $acl.SetAccessRule($rule) + Set-Acl -Path $directory.FullName -AclObject $acl + + #Authenticated Users ReadAndExecute - S-1-5-11 + $acl = Get-Acl -Path $directory.FullName + $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-11") + $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "ReadAndExecute","ContainerInherit,ObjectInherit","None","Allow") + $acl.SetAccessRule($rule) + Set-Acl -Path $directory.FullName -AclObject $acl + + return $True + } + return $False + } + catch { + return "Error" } - return $False } \ No newline at end of file diff --git a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 index de89e3c..5bfe644 100644 --- a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 +++ b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 @@ -74,12 +74,15 @@ function Invoke-PostUpdateActions { #Security check Write-Log "-> Checking Mods Directory:" "yellow" $Protected = Invoke-ModsProtect "$($WAUConfig.InstallLocation)\mods" - if ($Protected) { + if ($Protected -eq $True) { Write-Log "-> The mods directory is now secured!" "green" } - elseif (!$Protected) { + elseif ($Protected -eq $False) { Write-Log "-> The mods directory was already secured!" "green" } + else { + Write-Log "-> Error: The mods directory couldn't be verified as secured!" "red" + } #Convert about.xml if exists (previous WAU versions) to reg $WAUAboutPath = "$WorkingDir\config\about.xml" From 051cce9724f7160934412a664a9f5d8f6ba7f7b0 Mon Sep 17 00:00:00 2001 From: vincent-v-c Date: Fri, 10 Feb 2023 12:06:07 +0100 Subject: [PATCH 016/131] Update nl.xml --- Winget-AutoUpdate/locale/nl.xml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Winget-AutoUpdate/locale/nl.xml b/Winget-AutoUpdate/locale/nl.xml index c08bfed..1be3b3d 100644 --- a/Winget-AutoUpdate/locale/nl.xml +++ b/Winget-AutoUpdate/locale/nl.xml @@ -10,53 +10,53 @@ Geen internetverbinding. - Updates kon niet worden gecontroleerd. + Updates konden niet worden gecontroleerd. - {0} wordt geupdate! + {0} zal geüpdatet worden ! {0} to {1} - {0} geupdate. + {0} is geüpdatet. - Geinstalleerde versie: {0} + Geïnstalleerde versie: {0} - {0} kan niet worden geupdate! + {0} kan niet worden geüpdatet! Neem contact op met support. - Logs are not available yet! + Logs zijn nog niet beschikbaar ! - Starting a manual check for updated apps... + Start een manuele controle op software-updates... - Couldn't start a manual check for updated apps! + Kon geen manuele controle voor software-updates starten! - Check for updated apps already running... + Controleer of er al bijgewerkte apps actief zijn... - Manual check for updated apps completed... + Manuele controle op software-updates uitgevoerd... - See changelog + Zie changelog - Open log file + Open logbestand From 8143d08f9117327f1cc02d7572d77162d600357b Mon Sep 17 00:00:00 2001 From: vincent-v-c Date: Fri, 10 Feb 2023 12:20:13 +0100 Subject: [PATCH 017/131] Update nl.xml --- Winget-AutoUpdate/locale/nl.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Winget-AutoUpdate/locale/nl.xml b/Winget-AutoUpdate/locale/nl.xml index 1be3b3d..e69d9da 100644 --- a/Winget-AutoUpdate/locale/nl.xml +++ b/Winget-AutoUpdate/locale/nl.xml @@ -4,7 +4,7 @@ Controleer de netwerkverbinding. - Er kan op dit moment niet gecontroleerd worden op software-updates! + Er kan op dit moment niet gecontroleerd worden op software updates! @@ -36,19 +36,19 @@ - Start een manuele controle op software-updates... + Start een manuele controle op software updates... - Kon geen manuele controle voor software-updates starten! + Kon geen manuele controle voor software updates starten! - Controleer of er al bijgewerkte apps actief zijn... + Er wordt al naar software updates gezocht... - Manuele controle op software-updates uitgevoerd... + Manuele controle op software updates voltooid... From 5fea255c832a1d5ed89b0b5c37f73adf3ae12b9a Mon Sep 17 00:00:00 2001 From: vincent-v-c Date: Fri, 10 Feb 2023 12:21:07 +0100 Subject: [PATCH 018/131] Update nl.xml --- Winget-AutoUpdate/locale/nl.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Winget-AutoUpdate/locale/nl.xml b/Winget-AutoUpdate/locale/nl.xml index e69d9da..9e28c5b 100644 --- a/Winget-AutoUpdate/locale/nl.xml +++ b/Winget-AutoUpdate/locale/nl.xml @@ -40,7 +40,7 @@ - Kon geen manuele controle voor software updates starten! + Kon geen manuele controle op software updates starten! From 4cf00ac564f2e365edec8a2a05d9c7e715270603 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Tue, 14 Feb 2023 15:59:53 +0100 Subject: [PATCH 019/131] v1.16.2 --- Winget-AutoUpdate-Install.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Winget-AutoUpdate-Install.ps1 b/Winget-AutoUpdate-Install.ps1 index b836d5a..d7d486d 100644 --- a/Winget-AutoUpdate-Install.ps1 +++ b/Winget-AutoUpdate-Install.ps1 @@ -113,7 +113,7 @@ param( <# APP INFO #> -$WAUVersion = "1.16.1" +$WAUVersion = "1.16.2" <# FUNCTIONS #> From 1043f6b7d2c0ae0438187d1da1c14c7908ba722a Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Wed, 15 Feb 2023 02:56:48 +0100 Subject: [PATCH 020/131] Checking prerequisites --- .../functions/Invoke-PostUpdateActions.ps1 | 70 ++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 index 5bfe644..2bc08e0 100644 --- a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 +++ b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 @@ -3,7 +3,75 @@ function Invoke-PostUpdateActions { #log - Write-Log "Running Post Update actions..." "yellow" + Write-Log "Running Post Update actions:" "yellow" + + Write-Log "-> Checking prerequisites..." "yellow" + + #Check if Visual C++ 2019 or 2022 installed + $Visual2019 = "Microsoft Visual C++ 2015-2019 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 } + + #If not installed, install + if (!($path)) { + try { + if ((Get-CimInStance Win32_OperatingSystem).OSArchitecture -like "*64*") { + $OSArch = "x64" + } + else { + $OSArch = "x86" + } + Write-Log "-> Downloading VC_redist.$OSArch.exe..." + $SourceURL = "https://aka.ms/vs/17/release/VC_redist.$OSArch.exe" + $Installer = $($WAUConfig.InstallLocation) + "\VC_redist.$OSArch.exe" + $ProgressPreference = 'SilentlyContinue' + Invoke-WebRequest $SourceURL -OutFile (New-Item -Path $Installer -Force) + Write-Log "-> Installing VC_redist.$OSArch.exe..." + Start-Process -FilePath $Installer -Args "/quiet /norestart" -Wait + Remove-Item $Installer -ErrorAction Ignore + Write-Log "-> MS Visual C++ 2015-2022 installed successfully" "green" + } + catch { + Write-Log "-> MS Visual C++ 2015-2022 installation failed." "red" + } + } + else { + Write-Log "-> Prerequisites checked. OK" "green" + } + + Write-Log "-> Checking if Winget is installed" "yellow" + + #Check Package Install + $TestWinGet = Get-AppxProvisionedPackage -Online | Where-Object { $_.DisplayName -eq "Microsoft.DesktopAppInstaller" } + + #Current: v1.4.10173 = 1.19.10173.0 = 2023.118.406.0 + If ([Version]$TestWinGet.Version -ge "2023.118.406.0") { + + Write-Log "-> WinGet is Installed" "green" + + } + Else { + + #Download WinGet MSIXBundle + Write-Log "-> Not installed. Downloading WinGet..." + $WinGetURL = "https://github.com/microsoft/winget-cli/releases/download/v1.4.10173/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" + $WebClient = New-Object System.Net.WebClient + $WebClient.DownloadFile($WinGetURL, $($WAUConfig.InstallLocation) + "\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle") + + #Install WinGet MSIXBundle + try { + Write-Log "-> Installing Winget MSIXBundle for App Installer..." + Add-AppxProvisionedPackage -Online -PackagePath $($WAUConfig.InstallLocation) + "\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -SkipLicense | Out-Null + Write-Log "-> Installed Winget MSIXBundle for App Installer" "green" + } + catch { + Write-Log "-> Failed to intall Winget MSIXBundle for App Installer..." "red" + } + + #Remove WinGet MSIXBundle + Remove-Item -Path $($WAUConfig.InstallLocation) + "\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -Force -ErrorAction Continue + + } #Reset Winget Sources $ResolveWingetPath = Resolve-Path "$env:programfiles\WindowsApps\Microsoft.DesktopAppInstaller_*_*__8wekyb3d8bbwe\winget.exe" | Sort-Object { [version]($_.Path -replace '^[^\d]+_((\d+\.)*\d+)_.*', '$1') } From a668cdac40c0020b941e4c06c82c04eb2198ad7e Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Wed, 15 Feb 2023 21:00:51 +0100 Subject: [PATCH 021/131] Corrected Paths --- Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 index 2bc08e0..b8c004c 100644 --- a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 +++ b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 @@ -23,7 +23,7 @@ function Invoke-PostUpdateActions { } Write-Log "-> Downloading VC_redist.$OSArch.exe..." $SourceURL = "https://aka.ms/vs/17/release/VC_redist.$OSArch.exe" - $Installer = $($WAUConfig.InstallLocation) + "\VC_redist.$OSArch.exe" + $Installer = "$($WAUConfig.InstallLocation)\VC_redist.$OSArch.exe" $ProgressPreference = 'SilentlyContinue' Invoke-WebRequest $SourceURL -OutFile (New-Item -Path $Installer -Force) Write-Log "-> Installing VC_redist.$OSArch.exe..." @@ -56,12 +56,12 @@ function Invoke-PostUpdateActions { Write-Log "-> Not installed. Downloading WinGet..." $WinGetURL = "https://github.com/microsoft/winget-cli/releases/download/v1.4.10173/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" $WebClient = New-Object System.Net.WebClient - $WebClient.DownloadFile($WinGetURL, $($WAUConfig.InstallLocation) + "\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle") + $WebClient.DownloadFile($WinGetURL, "$($WAUConfig.InstallLocation)\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle") #Install WinGet MSIXBundle try { Write-Log "-> Installing Winget MSIXBundle for App Installer..." - Add-AppxProvisionedPackage -Online -PackagePath $($WAUConfig.InstallLocation) + "\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -SkipLicense | Out-Null + Add-AppxProvisionedPackage -Online -PackagePath "$($WAUConfig.InstallLocation)\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -SkipLicense | Out-Null Write-Log "-> Installed Winget MSIXBundle for App Installer" "green" } catch { @@ -69,7 +69,7 @@ function Invoke-PostUpdateActions { } #Remove WinGet MSIXBundle - Remove-Item -Path $($WAUConfig.InstallLocation) + "\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -Force -ErrorAction Continue + Remove-Item -Path "$($WAUConfig.InstallLocation)\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -Force -ErrorAction Continue } From d8779d681578baba354aabdd65594362458ea45f Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Wed, 15 Feb 2023 21:09:33 +0100 Subject: [PATCH 022/131] Text: up to date --- Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 index b8c004c..da0ba0c 100644 --- a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 +++ b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 @@ -39,7 +39,7 @@ function Invoke-PostUpdateActions { Write-Log "-> Prerequisites checked. OK" "green" } - Write-Log "-> Checking if Winget is installed" "yellow" + Write-Log "-> Checking if Winget is installed/up to date" "yellow" #Check Package Install $TestWinGet = Get-AppxProvisionedPackage -Online | Where-Object { $_.DisplayName -eq "Microsoft.DesktopAppInstaller" } @@ -47,13 +47,13 @@ function Invoke-PostUpdateActions { #Current: v1.4.10173 = 1.19.10173.0 = 2023.118.406.0 If ([Version]$TestWinGet.Version -ge "2023.118.406.0") { - Write-Log "-> WinGet is Installed" "green" + Write-Log "-> WinGet is Installed/up to date" "green" } Else { #Download WinGet MSIXBundle - Write-Log "-> Not installed. Downloading WinGet..." + Write-Log "-> Not installed/up to date. Downloading WinGet..." $WinGetURL = "https://github.com/microsoft/winget-cli/releases/download/v1.4.10173/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" $WebClient = New-Object System.Net.WebClient $WebClient.DownloadFile($WinGetURL, "$($WAUConfig.InstallLocation)\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle") From 6426e9faa8c28ac8f272066dfcfa9e81dfed4bb0 Mon Sep 17 00:00:00 2001 From: ghhanssen Date: Mon, 20 Feb 2023 09:37:46 +0100 Subject: [PATCH 023/131] Create nb.xml Norwegian --- Winget-AutoUpdate/locale/nb.xml | 62 +++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 Winget-AutoUpdate/locale/nb.xml diff --git a/Winget-AutoUpdate/locale/nb.xml b/Winget-AutoUpdate/locale/nb.xml new file mode 100644 index 0000000..c5768d1 --- /dev/null +++ b/Winget-AutoUpdate/locale/nb.xml @@ -0,0 +1,62 @@ + + + + + Sjekk nettverkstilkoblingen. + + Kan ikke se etter programvareoppdateringer for øyeblikket! + + + + Ingen internettforbindelse. + + Oppdateringer kunne ikke bekreftes. + + + + {0} vil bli oppdatert! + + {0} til {1} + + + + {0} oppdatert. + + Installert versjon: {0} + + + + {0} kunne ikke oppdateres! + + Vennligst kontakt support. + + + + Logger er ikke tilgjengelig ennå! + + + + Starter en manuell sjekk for oppdaterte apper... + + + + Kunne ikke starte en manuell sjekk for oppdaterte apper! + + + + Se etter oppdaterte apper som allerede kjører... + + + + Manuell sjekk for oppdaterte apper fullført... + + + + Se endringslogg + + + + Åpne loggfilen + + + From e3ad34128fecc42f95ab18c28f912f9012b5ca7f Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Mon, 20 Feb 2023 21:28:20 +0100 Subject: [PATCH 024/131] Text change --- Winget-AutoUpdate/locale/en.xml | 4 ++-- Winget-AutoUpdate/locale/sv.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Winget-AutoUpdate/locale/en.xml b/Winget-AutoUpdate/locale/en.xml index 6f927b0..99a3699 100644 --- a/Winget-AutoUpdate/locale/en.xml +++ b/Winget-AutoUpdate/locale/en.xml @@ -43,8 +43,8 @@ Couldn't start a manual check for updated apps! - - Check for updated apps already running... + + A manual check for updated apps already running... diff --git a/Winget-AutoUpdate/locale/sv.xml b/Winget-AutoUpdate/locale/sv.xml index 73bd603..5567458 100644 --- a/Winget-AutoUpdate/locale/sv.xml +++ b/Winget-AutoUpdate/locale/sv.xml @@ -43,8 +43,8 @@ Kunde inte starta en manuell koll efter uppdaterade appar! - - En koll efter uppdaterade appar körs redan... + + En manuell koll efter uppdaterade appar körs redan... From d6b45eb58a02ea8432d50a0d49b8c7302cce2750 Mon Sep 17 00:00:00 2001 From: ghhanssen Date: Tue, 21 Feb 2023 07:36:43 +0100 Subject: [PATCH 025/131] Update nb.xml Updated message in Norwegian --- Winget-AutoUpdate/locale/nb.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Winget-AutoUpdate/locale/nb.xml b/Winget-AutoUpdate/locale/nb.xml index c5768d1..0e1923c 100644 --- a/Winget-AutoUpdate/locale/nb.xml +++ b/Winget-AutoUpdate/locale/nb.xml @@ -44,7 +44,7 @@ - Se etter oppdaterte apper som allerede kjører... + Se etter oppdaterte apper kjører allerede... From eb2f9ff8c4fef3f1cee2ac649656e6a41fc5b135 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Wed, 22 Feb 2023 23:20:03 +0100 Subject: [PATCH 026/131] Resolve [Bug]: Install argument -UpdatesAtLogon and GPO setting #288 --- Winget-AutoUpdate/functions/Get-Policies.ps1 | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Winget-AutoUpdate/functions/Get-Policies.ps1 b/Winget-AutoUpdate/functions/Get-Policies.ps1 index 007593a..7ade848 100644 --- a/Winget-AutoUpdate/functions/Get-Policies.ps1 +++ b/Winget-AutoUpdate/functions/Get-Policies.ps1 @@ -225,8 +225,15 @@ Function Get-Policies { $definition = $task.Definition $definition.Triggers.Count | Out-Null if ($definition.Triggers.Count -gt 0) { - $triggers += New-ScheduledTaskTrigger -AtLogon - Set-ScheduledTask -TaskName "Winget-AutoUpdate" -Trigger $triggers + for($triggerId=1; $triggerId -le $definition.Triggers.Count; $triggerId++){ + if ($definition.Triggers.Item($triggerId).Type -eq "9") { + $triggerLogon = $True + } + } + if (!$triggerLogon) { + $triggers += New-ScheduledTaskTrigger -AtLogon + Set-ScheduledTask -TaskName "Winget-AutoUpdate" -Trigger $triggers + } } else { $tasktrigger = New-ScheduledTaskTrigger -AtLogon From 301c7eb3f380c4038ecf86aa6e495b36d5fa8554 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Thu, 23 Feb 2023 05:14:40 +0100 Subject: [PATCH 027/131] Better fix for [Bug]: Install argument -UpdatesAtLogon and GPO setting #288 --- Winget-AutoUpdate/functions/Get-Policies.ps1 | 21 ++++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/Winget-AutoUpdate/functions/Get-Policies.ps1 b/Winget-AutoUpdate/functions/Get-Policies.ps1 index 7ade848..5e4491f 100644 --- a/Winget-AutoUpdate/functions/Get-Policies.ps1 +++ b/Winget-AutoUpdate/functions/Get-Policies.ps1 @@ -223,21 +223,16 @@ Function Get-Policies { $folder = $service.GetFolder('\') $task = $folder.GetTask("Winget-AutoUpdate") $definition = $task.Definition - $definition.Triggers.Count | Out-Null - if ($definition.Triggers.Count -gt 0) { - for($triggerId=1; $triggerId -le $definition.Triggers.Count; $triggerId++){ - if ($definition.Triggers.Item($triggerId).Type -eq "9") { - $triggerLogon = $True - } - } - if (!$triggerLogon) { - $triggers += New-ScheduledTaskTrigger -AtLogon - Set-ScheduledTask -TaskName "Winget-AutoUpdate" -Trigger $triggers + $triggerLogon = $false + foreach ($trigger in $definition.Triggers) { + if ($trigger.Type -eq "9") { + $triggerLogon = $true + break } } - else { - $tasktrigger = New-ScheduledTaskTrigger -AtLogon - Set-ScheduledTask -TaskName "Winget-AutoUpdate" -Trigger $tasktrigger + if (!$triggerLogon) { + $triggers += New-ScheduledTaskTrigger -AtLogon + Set-ScheduledTask -TaskName "Winget-AutoUpdate" -Trigger $triggers } } else { From d307efe731efdb70967e27373ea621c40c1aa4d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=B6ran=20Axel=20Johannesson?= <102996177+KnifMelti@users.noreply.github.com> Date: Fri, 24 Feb 2023 01:07:56 +0100 Subject: [PATCH 028/131] Update en.xml --- Winget-AutoUpdate/locale/en.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Winget-AutoUpdate/locale/en.xml b/Winget-AutoUpdate/locale/en.xml index 99a3699..b7c6479 100644 --- a/Winget-AutoUpdate/locale/en.xml +++ b/Winget-AutoUpdate/locale/en.xml @@ -43,8 +43,8 @@ Couldn't start a manual check for updated apps! - - A manual check for updated apps already running... + + A check for updated apps already running... From 4fede77805f33915e0274c0b5e6aa0679fc334ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=B6ran=20Axel=20Johannesson?= <102996177+KnifMelti@users.noreply.github.com> Date: Fri, 24 Feb 2023 01:10:55 +0100 Subject: [PATCH 029/131] Update sv.xml --- Winget-AutoUpdate/locale/sv.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Winget-AutoUpdate/locale/sv.xml b/Winget-AutoUpdate/locale/sv.xml index 5567458..8e0de4a 100644 --- a/Winget-AutoUpdate/locale/sv.xml +++ b/Winget-AutoUpdate/locale/sv.xml @@ -43,8 +43,8 @@ Kunde inte starta en manuell koll efter uppdaterade appar! - - En manuell koll efter uppdaterade appar körs redan... + + En koll efter uppdaterade appar körs redan... From 62b943afc75bbecda821f7f52ad67d4ec107cc2c Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Fri, 3 Mar 2023 20:15:59 +0100 Subject: [PATCH 030/131] [Feature Request]: -ListPath is a directory #289 and [Feature Request]: Log file location #291 --- README.md | 5 ++- Winget-AutoUpdate-Install.ps1 | 18 +++----- .../functions/Invoke-PostUpdateActions.ps1 | 6 +++ Winget-AutoUpdate/functions/Start-Init.ps1 | 43 +++++++++++++++---- 4 files changed, 50 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 39c476a..4565279 100644 --- a/README.md +++ b/README.md @@ -96,12 +96,15 @@ Disable Winget-AutoUpdate update checking. By default, WAU auto updates if new v Use White List instead of Black List. This setting will not create the "excluded_apps.txt" but "included_apps.txt". **-ListPath** -Get Black/White List from external Path (**URL/UNC/GPO/Local**) - download/copy to Winget-AutoUpdate installation location if external list is newer. +Get Black/White List from external Path (**URL/UNC/Local/GPO**) - download/copy to Winget-AutoUpdate installation location if external list is newer. +The parameter should only contain a **PATH** (not the filename)! + If `-ListPath` is set to **GPO** the Black/White List can be managed from within the GPO itself under **Application GPO Blacklist**/**Application GPO Whitelist**. Thanks to [Weatherlights](https://github.com/Weatherlights) in [#256 (reply in thread)](https://github.com/Romanitho/Winget-AutoUpdate/discussions/256#discussioncomment-4710599)! **-ModsPath** Get Mods from external Path (**URL/UNC/Local**) - download/copy to `mods` in Winget-AutoUpdate installation location if external mods are newer. +The parameter should only contain a **PATH** (not the filename)! For **URL**: This requires a site directory with **Directory Listing Enabled** and no index page overriding the listing of files (or an index page with href listing of all the **Mods** to be downloaded): ``` diff --git a/Winget-AutoUpdate-Install.ps1 b/Winget-AutoUpdate-Install.ps1 index d7d486d..99f4c2f 100644 --- a/Winget-AutoUpdate-Install.ps1 +++ b/Winget-AutoUpdate-Install.ps1 @@ -367,18 +367,9 @@ function Install-WingetAutoUpdate { New-ItemProperty $regPath -Name WAU_BypassListForUsers -Value 1 -PropertyType DWord -Force | Out-Null } - #Set ACL for Authenticated Users on logfile - $LogFile = "$WingetUpdatePath\logs\updates.log" - if (test-path $LogFile) { - $NewAcl = Get-Acl -Path $LogFile - $identity = New-Object System.Security.Principal.SecurityIdentifier S-1-5-11 - $fileSystemRights = "Modify" - $type = "Allow" - $fileSystemAccessRuleArgumentList = $identity, $fileSystemRights, $type - $fileSystemAccessRule = New-Object -TypeName System.Security.AccessControl.FileSystemAccessRule -ArgumentList $fileSystemAccessRuleArgumentList - $NewAcl.SetAccessRule($fileSystemAccessRule) - Set-Acl -Path $LogFile -AclObject $NewAcl - } + #Log file and symlink initialization + . "$WingetUpdatePath\functions\Start-Init.ps1" + Start-Init #Security check Write-host "`nChecking Mods Directory:" -ForegroundColor Yellow @@ -434,6 +425,9 @@ function Uninstall-WingetAutoUpdate { if (!$NoClean) { Remove-Item $InstallLocation -Force -Recurse + if (Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-updates.log") { + Remove-Item -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-updates.log" -Force -ErrorAction SilentlyContinue | Out-Null + } } else { #Keep critical files diff --git a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 index da0ba0c..f1d314d 100644 --- a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 +++ b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 @@ -5,6 +5,12 @@ function Invoke-PostUpdateActions { #log Write-Log "Running Post Update actions:" "yellow" + #Check if Intune Management Extension Logs folder and WAU-updates.log exists, make symlink + if ((Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs") -and !(Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-updates.log")) { + Write-log "-> Creating SymLink for log file in Intune Management Extension log folder" "yellow" + New-Item -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-updates.log" -ItemType SymbolicLink -Value $LogFile -Force -ErrorAction SilentlyContinue | Out-Null + } + Write-Log "-> Checking prerequisites..." "yellow" #Check if Visual C++ 2019 or 2022 installed diff --git a/Winget-AutoUpdate/functions/Start-Init.ps1 b/Winget-AutoUpdate/functions/Start-Init.ps1 index 280ecbb..14c90bf 100644 --- a/Winget-AutoUpdate/functions/Start-Init.ps1 +++ b/Winget-AutoUpdate/functions/Start-Init.ps1 @@ -5,16 +5,21 @@ function Start-Init { #Config console output encoding [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 - #Log Header - $Log = "`n##################################################`n# CHECK FOR APP UPDATES - $(Get-Date -Format (Get-culture).DateTimeFormat.ShortDatePattern)`n##################################################" - $Log | Write-host - - #Logs initialisation - $Script:LogFile = "$WorkingDir\logs\updates.log" + $caller = Get-ChildItem $MyInvocation.PSCommandPath | Select-Object -Expand Name + if ($caller -eq "Winget-Upgrade.ps1") { + #Log Header + $Log = "`n##################################################`n# CHECK FOR APP UPDATES - $(Get-Date -Format (Get-culture).DateTimeFormat.ShortDatePattern)`n##################################################" + $Log | Write-host + #Logs initialisation + $Script:LogFile = "$WorkingDir\logs\updates.log" + } + elseif ($caller -eq "Winget-AutoUpdate-Install.ps1") { + $Script:LogFile = "$WingetUpdatePath\logs\updates.log" + } if (!(Test-Path $LogFile)) { #Create file if doesn't exist - New-Item -ItemType File -Path $LogFile -Force + New-Item -ItemType File -Path $LogFile -Force | Out-Null #Set ACL for users on logfile $NewAcl = Get-Acl -Path $LogFile @@ -26,8 +31,28 @@ function Start-Init { $NewAcl.SetAccessRule($fileSystemAccessRule) Set-Acl -Path $LogFile -AclObject $NewAcl } + elseif ((Test-Path $LogFile) -and ($caller -eq "Winget-AutoUpdate-Install.ps1")) { + #Set ACL for users on logfile + $NewAcl = Get-Acl -Path $LogFile + $identity = New-Object System.Security.Principal.SecurityIdentifier S-1-5-11 + $fileSystemRights = "Modify" + $type = "Allow" + $fileSystemAccessRuleArgumentList = $identity, $fileSystemRights, $type + $fileSystemAccessRule = New-Object -TypeName System.Security.AccessControl.FileSystemAccessRule -ArgumentList $fileSystemAccessRuleArgumentList + $NewAcl.SetAccessRule($fileSystemAccessRule) + Set-Acl -Path $LogFile -AclObject $NewAcl + } - #Log file - $Log | out-file -filepath $LogFile -Append + #Check if Intune Management Extension Logs folder and WAU-updates.log exists, make symlink + if ((Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs") -and !(Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-updates.log")) { + Write-host "`nCreating SymLink for log file in Intune Management Extension log folder" -ForegroundColor Yellow + New-Item -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-updates.log" -ItemType SymbolicLink -Value $LogFile -Force -ErrorAction SilentlyContinue | Out-Null + } + + + if ($caller -eq "Winget-Upgrade.ps1") { + #Log file + $Log | out-file -filepath $LogFile -Append + } } From b443c21df7bfcd02c197f03120e52cdc959c7bb7 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sat, 4 Mar 2023 05:36:03 +0100 Subject: [PATCH 031/131] PATH error message --- Winget-AutoUpdate/Winget-Upgrade.ps1 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Winget-AutoUpdate/Winget-Upgrade.ps1 b/Winget-AutoUpdate/Winget-Upgrade.ps1 index 39e4285..1a1b222 100644 --- a/Winget-AutoUpdate/Winget-Upgrade.ps1 +++ b/Winget-AutoUpdate/Winget-Upgrade.ps1 @@ -116,6 +116,9 @@ if (Test-Network) { $NewList = Test-ListPath $WAUConfig.WAU_ListPath.TrimEnd(" ", "\", "/") $WAUConfig.WAU_UseWhiteList $WAUConfig.InstallLocation.TrimEnd(" ", "\") if ($ReachNoPath) { Write-Log "Couldn't reach/find/compare/copy from $($WAUConfig.WAU_ListPath.TrimEnd(" ", "\", "/"))..." "Red" + if ($($WAUConfig.WAU_ListPath) -match "_apps.txt") { + Write-Log "PATH must end with a Directory, not a File..." "Red" + } $Script:ReachNoPath = $False } if ($NewList) { @@ -143,6 +146,9 @@ if (Test-Network) { $NewMods, $DeletedMods = Test-ModsPath $WAUConfig.WAU_ModsPath.TrimEnd(" ", "\", "/") $WAUConfig.InstallLocation.TrimEnd(" ", "\") if ($ReachNoPath) { Write-Log "Couldn't reach/find/compare/copy from $($WAUConfig.WAU_ModsPath.TrimEnd(" ", "\", "/"))..." "Red" + if ($($WAUConfig.WAU_ModsPath) -match "_apps.txt") { + Write-Log "PATH must end with a Directory, not a File..." "Red" + } $Script:ReachNoPath = $False } if ($NewMods -gt 0) { From aabe7afc2df79345879dce51645618b0d98d525f Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sat, 4 Mar 2023 05:52:21 +0100 Subject: [PATCH 032/131] No File error text in ModsPath --- Winget-AutoUpdate/Winget-Upgrade.ps1 | 3 --- 1 file changed, 3 deletions(-) diff --git a/Winget-AutoUpdate/Winget-Upgrade.ps1 b/Winget-AutoUpdate/Winget-Upgrade.ps1 index 1a1b222..873c5af 100644 --- a/Winget-AutoUpdate/Winget-Upgrade.ps1 +++ b/Winget-AutoUpdate/Winget-Upgrade.ps1 @@ -146,9 +146,6 @@ if (Test-Network) { $NewMods, $DeletedMods = Test-ModsPath $WAUConfig.WAU_ModsPath.TrimEnd(" ", "\", "/") $WAUConfig.InstallLocation.TrimEnd(" ", "\") if ($ReachNoPath) { Write-Log "Couldn't reach/find/compare/copy from $($WAUConfig.WAU_ModsPath.TrimEnd(" ", "\", "/"))..." "Red" - if ($($WAUConfig.WAU_ModsPath) -match "_apps.txt") { - Write-Log "PATH must end with a Directory, not a File..." "Red" - } $Script:ReachNoPath = $False } if ($NewMods -gt 0) { From c4b103a6337b5068849caaca88bc8d8608d940bc Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sun, 5 Mar 2023 18:30:33 +0100 Subject: [PATCH 033/131] Small bits --- README.md | 3 +-- Winget-AutoUpdate/Winget-Upgrade.ps1 | 27 ++++++++++++++++++--------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 4565279..0c215f4 100644 --- a/README.md +++ b/README.md @@ -97,14 +97,13 @@ Use White List instead of Black List. This setting will not create the "excluded **-ListPath** Get Black/White List from external Path (**URL/UNC/Local/GPO**) - download/copy to Winget-AutoUpdate installation location if external list is newer. -The parameter should only contain a **PATH** (not the filename)! +**PATH** must end with a Directory, not a File... If `-ListPath` is set to **GPO** the Black/White List can be managed from within the GPO itself under **Application GPO Blacklist**/**Application GPO Whitelist**. Thanks to [Weatherlights](https://github.com/Weatherlights) in [#256 (reply in thread)](https://github.com/Romanitho/Winget-AutoUpdate/discussions/256#discussioncomment-4710599)! **-ModsPath** Get Mods from external Path (**URL/UNC/Local**) - download/copy to `mods` in Winget-AutoUpdate installation location if external mods are newer. -The parameter should only contain a **PATH** (not the filename)! For **URL**: This requires a site directory with **Directory Listing Enabled** and no index page overriding the listing of files (or an index page with href listing of all the **Mods** to be downloaded): ``` diff --git a/Winget-AutoUpdate/Winget-Upgrade.ps1 b/Winget-AutoUpdate/Winget-Upgrade.ps1 index 873c5af..6f78139 100644 --- a/Winget-AutoUpdate/Winget-Upgrade.ps1 +++ b/Winget-AutoUpdate/Winget-Upgrade.ps1 @@ -111,13 +111,21 @@ if (Test-Network) { #Get External ListPath if run as System if ($WAUConfig.WAU_ListPath) { - Write-Log "WAU uses External Lists from: $($WAUConfig.WAU_ListPath.TrimEnd(" ", "\", "/"))" - if ($($WAUConfig.WAU_ListPath) -ne "GPO") { - $NewList = Test-ListPath $WAUConfig.WAU_ListPath.TrimEnd(" ", "\", "/") $WAUConfig.WAU_UseWhiteList $WAUConfig.InstallLocation.TrimEnd(" ", "\") + $ListPathClean = $($WAUConfig.WAU_ListPath.TrimEnd(" ", "\", "/")) + Write-Log "WAU uses External Lists from: $ListPathClean" + if ($ListPathClean -ne "GPO") { + $NewList = Test-ListPath $ListPathClean $WAUConfig.WAU_UseWhiteList $WAUConfig.InstallLocation.TrimEnd(" ", "\") if ($ReachNoPath) { - Write-Log "Couldn't reach/find/compare/copy from $($WAUConfig.WAU_ListPath.TrimEnd(" ", "\", "/"))..." "Red" - if ($($WAUConfig.WAU_ListPath) -match "_apps.txt") { - Write-Log "PATH must end with a Directory, not a File..." "Red" + Write-Log "Couldn't reach/find/compare/copy from $ListPathClean..." "Red" + if ($ListPathClean -notlike "http*") { + if (Test-Path -Path "$ListPathClean" -PathType Leaf) { + Write-Log "PATH must end with a Directory, not a File..." "Red" + } + } + else { + if ($ListPathClean -match "_apps.txt") { + Write-Log "PATH must end with a Directory, not a File..." "Red" + } } $Script:ReachNoPath = $False } @@ -142,10 +150,11 @@ if (Test-Network) { #Get External ModsPath if run as System if ($WAUConfig.WAU_ModsPath) { - Write-Log "WAU uses External Mods from: $($WAUConfig.WAU_ModsPath.TrimEnd(" ", "\", "/"))" - $NewMods, $DeletedMods = Test-ModsPath $WAUConfig.WAU_ModsPath.TrimEnd(" ", "\", "/") $WAUConfig.InstallLocation.TrimEnd(" ", "\") + $ModsPathClean = $($WAUConfig.WAU_ModsPath.TrimEnd(" ", "\", "/")) + Write-Log "WAU uses External Mods from: $ModsPathClean" + $NewMods, $DeletedMods = Test-ModsPath $ModsPathClean $WAUConfig.InstallLocation.TrimEnd(" ", "\") if ($ReachNoPath) { - Write-Log "Couldn't reach/find/compare/copy from $($WAUConfig.WAU_ModsPath.TrimEnd(" ", "\", "/"))..." "Red" + Write-Log "Couldn't reach/find/compare/copy from $ModsPathClean..." "Red" $Script:ReachNoPath = $False } if ($NewMods -gt 0) { From 3a3f0760082d80c2ba2bd91cf18bc9e9890c202b Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sun, 5 Mar 2023 18:38:34 +0100 Subject: [PATCH 034/131] SymLink in README --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0c215f4..2645be7 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,8 @@ By default, scripts and components will be placed in ProgramData location (insid From version 1.9.0 (on new installations) WAU runs everyday at 6AM. You can now configure the frequency with `-UpdatesInterval` option (Daily, BiDaily, Weekly, BiWeekly or Monthly). You can also add `-UpdatesAtLogon` parameter to run at user logon and keep this option activated like previous versions (recommanded). ### Log location -You can find logs in install location, in logs folder. +You can find logs in install location, in logs folder. +If **Intune Management Extension** is installed, a **SymLink** (WAU-updates.log) is created under **C:\ProgramData\Microsoft\IntuneManagementExtension\Logs** ### "Unknown" App version As explained in this [post](https://github.com/microsoft/winget-cli/issues/1255), Winget cannot detect the current version of some installed apps. We decided to skip managing these apps with WAU to avoid retries each time WAU runs: From e1d00e38b2de56a293dcd70af832a394ab918c78 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Mon, 6 Mar 2023 15:22:53 +0100 Subject: [PATCH 035/131] V1.16.4 --- Winget-AutoUpdate-Install.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Winget-AutoUpdate-Install.ps1 b/Winget-AutoUpdate-Install.ps1 index 99f4c2f..c7a5a0a 100644 --- a/Winget-AutoUpdate-Install.ps1 +++ b/Winget-AutoUpdate-Install.ps1 @@ -113,7 +113,7 @@ param( <# APP INFO #> -$WAUVersion = "1.16.2" +$WAUVersion = "1.16.4" <# FUNCTIONS #> From 92a39fb9d1a094bcdb0a48be30db81e9cc02f64d Mon Sep 17 00:00:00 2001 From: RedEchidnaUK Date: Tue, 7 Mar 2023 15:17:40 +0000 Subject: [PATCH 036/131] Added AZBlob for Mods --- Policies/WAU.admx | 12 ++++- Policies/en-US/WAU.adml | 22 ++++++-- README.md | 7 ++- Winget-AutoUpdate-Install.ps1 | 13 +++-- Winget-AutoUpdate/Winget-Upgrade.ps1 | 4 +- Winget-AutoUpdate/functions/Get-AZCopy.ps1 | 50 +++++++++++++++++++ Winget-AutoUpdate/functions/Get-Policies.ps1 | 8 +++ Winget-AutoUpdate/functions/Test-ModsPath.ps1 | 41 ++++++++++++++- 8 files changed, 143 insertions(+), 14 deletions(-) create mode 100644 Winget-AutoUpdate/functions/Get-AZCopy.ps1 diff --git a/Policies/WAU.admx b/Policies/WAU.admx index 146524e..3106d8b 100644 --- a/Policies/WAU.admx +++ b/Policies/WAU.admx @@ -1,12 +1,13 @@ - + - + + @@ -99,6 +100,13 @@ + + + + + + + diff --git a/Policies/en-US/WAU.adml b/Policies/en-US/WAU.adml index c9545de..e9d1f05 100644 --- a/Policies/en-US/WAU.adml +++ b/Policies/en-US/WAU.adml @@ -1,11 +1,12 @@ - + WinGet-AutoUpdate WinGet-AutoUpdate GPO Management Winget-AutoUpdate Winget-AutoUpdate version 1.16.0 or later + Winget-AutoUpdate version 1.16.5 or later Activate WAU GPO Management This policy setting is an overriding toggle for GPO Management of Winget-AutoUpdate. Bypass Black/White list for User @@ -43,10 +44,16 @@ If this policy is disabled or not configured, the default is No. If "Application GPO Blacklist/Whitelist" is set in this GPO the Path can be: GPO If this policy is disabled or not configured, the default ListPath is used (WAU InstallLocation). - Get Mods from external Path (URL/UNC/Local) - If this policy is enabled, you can set a (URL/UNC/Local) Path to external mods other than the default. + Get Mods from external Path (URL/UNC/Local/AzureBlob) + If this policy is enabled, you can set a (URL/UNC/Local/AzureBlob) Path to external mods other than the default. -If this policy is disabled or not configured, the default ModsPath is used (WAU InstallLocation). +If this policy is disabled or not configured, the default ModsPath is used (WAU InstallLocation). + +Note: When set to 'AzureBlob', ensure you also configure 'Set Azure Blob URL with SAS token'. + Set Azure Blob URL with SAS Token + If this policy is enabled, you can set an Azure Storage Blob URL with SAS token for use with the 'Mods' feature. The URL must include the SAS token and have 'read' and 'list' permissions. + +If this policy is disabled or not configured, the value is blank and Azure Blob storage will NOT work. Notification Level If this policy is enabled, you can configure the Notification Level: 1. Full (Default) @@ -148,8 +155,13 @@ If this policy is disabled or not configured, the default size is used. - + + + + + + diff --git a/README.md b/README.md index 2645be7..fabd11c 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ If `-ListPath` is set to **GPO** the Black/White List can be managed from within Thanks to [Weatherlights](https://github.com/Weatherlights) in [#256 (reply in thread)](https://github.com/Romanitho/Winget-AutoUpdate/discussions/256#discussioncomment-4710599)! **-ModsPath** -Get Mods from external Path (**URL/UNC/Local**) - download/copy to `mods` in Winget-AutoUpdate installation location if external mods are newer. +Get Mods from external Path (**URL/UNC/Local/AzureBlob**) - download/copy to `mods` in Winget-AutoUpdate installation location if external mods are newer. For **URL**: This requires a site directory with **Directory Listing Enabled** and no index page overriding the listing of files (or an index page with href listing of all the **Mods** to be downloaded): ``` @@ -121,6 +121,11 @@ Validated on **IIS/Apache**. - The extension **.ps1** must be added as **MIME Types** (text/powershell-script) otherwise it's displayed in the listing but can't be opened - Files with special characters in the filename can't be opened by default from an IIS server - config must be administrated: **Enable Allow double escaping** in '**Request Filtering**' +For **AzureBlob**: This requires the parameter **-AzureBlobURL** to be set with an appropriate Azure Blob Storage URL including the SAS token. See **-AzureBlobURL** for more information. + +**-AzureBlobURL** +Used in conjunction with the **-ModsPath** parameter to provide the Azure Storage Blob URL with SAS token. The SAS token must, at a minimum, have 'Read' and 'List' permissions. It is recommended to set the permisions at the container level and rotate the SAS token on a regular basis. Ensure the container reflects the same structure as found under the initial `mods` folder. (From version 1.16.4). + **-InstallUserContext** Install WAU with system and **user** context executions (From version 1.15.3). diff --git a/Winget-AutoUpdate-Install.ps1 b/Winget-AutoUpdate-Install.ps1 index c7a5a0a..741b439 100644 --- a/Winget-AutoUpdate-Install.ps1 +++ b/Winget-AutoUpdate-Install.ps1 @@ -29,10 +29,13 @@ Disable Winget-AutoUpdate update checking. By default, WAU auto update if new ve Use White List instead of Black List. This setting will not create the "exclude_apps.txt" but "include_apps.txt" .PARAMETER ListPath -Get Black/White List from Path (URL/UNC/Local) +Get Black/White List from Path (URL/UNC/GPO/Local) .PARAMETER ModsPath -Get mods from Path (URL/UNC/Local) +Get mods from Path (URL/UNC/Local/AzureBlob) + +.PARAMETER AzureBlobURL +Set the Azure Storage Blob URL including the SAS token. The token requires at a minimum 'Read' and 'List' permissions. It is recommended to set this at the container level .PARAMETER Uninstall Remove scheduled tasks and scripts. @@ -93,6 +96,7 @@ param( [Parameter(Mandatory = $False)] [Alias('Path')] [String] $WingetUpdatePath = "$env:ProgramData\Winget-AutoUpdate", [Parameter(Mandatory = $False)] [Alias('List')] [String] $ListPath, [Parameter(Mandatory = $False)] [Alias('Mods')] [String] $ModsPath, + [Parameter(Mandatory = $False)] [Alias('AzureBlobURL')] [String] $AzureBlobSASURL, [Parameter(Mandatory = $False)] [Switch] $DoNotUpdate = $false, [Parameter(Mandatory = $False)] [Switch] $DisableWAUAutoUpdate = $false, [Parameter(Mandatory = $False)] [Switch] $RunOnMetered = $false, @@ -113,7 +117,7 @@ param( <# APP INFO #> -$WAUVersion = "1.16.4" +$WAUVersion = "1.16.5" <# FUNCTIONS #> @@ -363,6 +367,9 @@ function Install-WingetAutoUpdate { if ($ModsPath) { New-ItemProperty $regPath -Name WAU_ModsPath -Value $ModsPath -Force | Out-Null } + if ($AzureBlobSASURL) { + New-ItemProperty $regPath -Name WAU_AzureBlobSASURL -Value $AzureBlobSASURL -Force | Out-Null + } if ($BypassListForUsers) { New-ItemProperty $regPath -Name WAU_BypassListForUsers -Value 1 -PropertyType DWord -Force | Out-Null } diff --git a/Winget-AutoUpdate/Winget-Upgrade.ps1 b/Winget-AutoUpdate/Winget-Upgrade.ps1 index 6f78139..c0d2fd5 100644 --- a/Winget-AutoUpdate/Winget-Upgrade.ps1 +++ b/Winget-AutoUpdate/Winget-Upgrade.ps1 @@ -87,7 +87,7 @@ if (Test-Network) { $WAUDisableAutoUpdate = $WAUConfig.WAU_DisableAutoUpdate #If yes then check WAU update if run as System if ($WAUDisableAutoUpdate -eq 1) { - Write-Log "WAU AutoUpdate is Disabled." "Grey" + Write-Log "WAU AutoUpdate is Disabled." "Gray" } else { Write-Log "WAU AutoUpdate is Enabled." "Green" @@ -152,7 +152,7 @@ if (Test-Network) { if ($WAUConfig.WAU_ModsPath) { $ModsPathClean = $($WAUConfig.WAU_ModsPath.TrimEnd(" ", "\", "/")) Write-Log "WAU uses External Mods from: $ModsPathClean" - $NewMods, $DeletedMods = Test-ModsPath $ModsPathClean $WAUConfig.InstallLocation.TrimEnd(" ", "\") + $NewMods, $DeletedMods = Test-ModsPath $ModsPathClean $WAUConfig.InstallLocation.TrimEnd(" ", "\") $WAUConfig.WAU_AzureBlobSASURL.TrimEnd(" ") if ($ReachNoPath) { Write-Log "Couldn't reach/find/compare/copy from $ModsPathClean..." "Red" $Script:ReachNoPath = $False diff --git a/Winget-AutoUpdate/functions/Get-AZCopy.ps1 b/Winget-AutoUpdate/functions/Get-AZCopy.ps1 new file mode 100644 index 0000000..bfe7994 --- /dev/null +++ b/Winget-AutoUpdate/functions/Get-AZCopy.ps1 @@ -0,0 +1,50 @@ +#Function to get AZCopy if it doesn't exist and update it if it does + +Function Get-AZCopy ($WingetUpdatePath){ + + $AZCopyLink = (Invoke-WebRequest -Uri https://aka.ms/downloadazcopy-v10-windows -MaximumRedirection 0 -ErrorAction SilentlyContinue).headers.location + $AZCopyVersionRegex = [regex]::new("(\d+\.\d+\.\d+)") + $AZCopyLatestVersion = $AZCopyVersionRegex.Match($AZCopyLink).Value + + if ($null -eq $AZCopyLatestVersion -or "" -eq $AZCopyLatestVersion) { + $AZCopyLatestVersion = "0.0.0" + } + + if (Test-Path -Path "$WingetUpdatePath\azcopy.exe" -PathType Leaf) { + $AZCopyCurrentVersion = & "$WingetUpdatePath\azcopy.exe" -v + $AZCopyCurrentVersion = $AZCopyVersionRegex.Match($AZCopyCurrentVersion).Value + Write-Log "AZCopy version $AZCopyCurrentVersion found" + } + else { + Write-Log "AZCopy not already installed" + $AZCopyCurrentVersion = "0.0.0" + } + + if (([version] $AZCopyCurrentVersion) -lt ([version] $AZCopyLatestVersion)) { + Write-Log "Installing version $AZCopyLatestVersion of AZCopy" + Invoke-WebRequest -Uri $AZCopyLink -OutFile "$WingetUpdatePath\azcopyv10.zip" + Write-Log "Extracting AZCopy zip file" + + Expand-archive -Path "$WingetUpdatePath\azcopyv10.zip" -Destinationpath "$WingetUpdatePath" -Force + + $AZCopyPathSearch = Resolve-Path -path "$WingetUpdatePath\azcopy_*" + + if ($AZCopyPathSearch -is [array]) { + $AZCopyEXEPath = $AZCopyPathSearch[$AZCopyPathSearch.Length - 1] + } + else { + $AZCopyEXEPath = $AZCopyPathSearch + } + + Write-Log "Copying 'azcopy.exe' to main folder" + Copy-Item "$AZCopyEXEPath\azcopy.exe" -Destination "$WingetUpdatePath\" + + Write-Log "Removing temporary AZCopy files" + Remove-Item -Path $AZCopyEXEPath -Recurse + Remove-Item -Path "$WingetUpdatePath\azcopyv10.zip" + + $AZCopyCurrentVersion = & "$WingetUpdatePath\azcopy.exe" -v + $AZCopyCurrentVersion = $AZCopyVersionRegex.Match($AZCopyCurrentVersion).Value + Write-Log "AZCopy version $AZCopyCurrentVersion installed" + } +} \ No newline at end of file diff --git a/Winget-AutoUpdate/functions/Get-Policies.ps1 b/Winget-AutoUpdate/functions/Get-Policies.ps1 index 5e4491f..bad0ee1 100644 --- a/Winget-AutoUpdate/functions/Get-Policies.ps1 +++ b/Winget-AutoUpdate/functions/Get-Policies.ps1 @@ -69,6 +69,14 @@ Function Get-Policies { Remove-ItemProperty $regPath -Name WAU_ModsPath -Force -ErrorAction SilentlyContinue | Out-Null $ChangedSettings++ } + if ($null -ne $($WAUPolicies.WAU_AzureBlobSASURL) -and ($($WAUPolicies.WAU_AzureBlobSASURL) -ne $($WAUConfig.WAU_AzureBlobSASURL))) { + New-ItemProperty $regPath -Name WAU_AzureBlobSASURL -Value $($WAUPolicies.WAU_AzureBlobSASURL.TrimEnd(" ", "\", "/")) -Force | Out-Null + $ChangedSettings++ + } + elseif ($null -eq $($WAUPolicies.WAU_AzureBlobSASURL) -and $($WAUConfig.WAU_AzureBlobSASURL)) { + Remove-ItemProperty $regPath -Name WAU_AzureBlobSASURL -Force -ErrorAction SilentlyContinue | Out-Null + $ChangedSettings++ + } if ($null -ne $($WAUPolicies.WAU_NotificationLevel) -and ($($WAUPolicies.WAU_NotificationLevel) -ne $($WAUConfig.WAU_NotificationLevel))) { New-ItemProperty $regPath -Name WAU_NotificationLevel -Value $($WAUPolicies.WAU_NotificationLevel) -Force | Out-Null diff --git a/Winget-AutoUpdate/functions/Test-ModsPath.ps1 b/Winget-AutoUpdate/functions/Test-ModsPath.ps1 index 29f0bdf..e9deb5e 100644 --- a/Winget-AutoUpdate/functions/Test-ModsPath.ps1 +++ b/Winget-AutoUpdate/functions/Test-ModsPath.ps1 @@ -1,6 +1,6 @@ #Function to check Mods External Path -function Test-ModsPath ($ModsPath, $WingetUpdatePath) { +function Test-ModsPath ($ModsPath, $WingetUpdatePath, $AzureBlobSASURL) { # URL, UNC or Local Path # Get local and external Mods paths $LocalMods = -join ($WingetUpdatePath, "\", "mods") @@ -134,6 +134,45 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) { } return $ModsUpdated, $DeletedMods } + # If Path is Azure Blob + elseif ($ExternalMods -like "AzureBlob") { + Write-Log "Azure Blob Storage set as mod source" + Write-Log "Checking AZCopy" + Get-AZCopy $WingetUpdatePath + #Safety check to make sure we really do have azcopy.exe and a Blob URL + if ((Test-Path -Path "$WingetUpdatePath\azcopy.exe" -PathType Leaf) -and ($null -ne $AzureBlobSASURL)) { + Write-Log "Syncing Blob storage with local storage" + + $AZCopySyncOutput = & $WingetUpdatePath\azcopy.exe sync "$AzureBlobSASURL" "$LocalMods" --from-to BlobLocal --delete-destination=true + $AZCopyOutputLines = $AZCopySyncOutput.Split([Environment]::NewLine) + + foreach( $_ in $AZCopyOutputLines){ + $AZCopySyncAdditionsRegex = [regex]::new("(?<=Number of Copy Transfers Completed:\s+)\d+") + $AZCopySyncDeletionsRegex = [regex]::new("(?<=Number of Deletions at Destination:\s+)\d+") + $AZCopySyncErrorRegex = [regex]::new("^Cannot perform sync due to error:") + + $AZCopyAdditions = [int] $AZCopySyncAdditionsRegex.Match($_).Value + $AZCopyDeletions = [int] $AZCopySyncDeletionsRegex.Match($_).Value + + if ($AZCopyAdditions -ne 0){ + $ModsUpdated = $AZCopyAdditions + } + + if ($AZCopyDeletions -ne 0){ + $DeletedMods = $AZCopyDeletions + } + + if ($AZCopySyncErrorRegex.Match($_).Value){ + Write-Log "AZCopy Sync Error! $_" + } + } + } + else { + Write-Log "Error 'azcopy.exe' or SAS Token not found!" + } + + return $ModsUpdated, $DeletedMods + } # If path is UNC or local else { $ExternalBins = "$ModsPath\bins" From 8db278fd817462ef29824f3488f393a2242a23ce Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Tue, 14 Mar 2023 11:48:25 +0100 Subject: [PATCH 037/131] v1.17.0 --- Winget-AutoUpdate-Install.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Winget-AutoUpdate-Install.ps1 b/Winget-AutoUpdate-Install.ps1 index 741b439..c6f1c15 100644 --- a/Winget-AutoUpdate-Install.ps1 +++ b/Winget-AutoUpdate-Install.ps1 @@ -117,7 +117,7 @@ param( <# APP INFO #> -$WAUVersion = "1.16.5" +$WAUVersion = "1.17.0" <# FUNCTIONS #> From 38946d6d496faa22d4b7b8d49aec0152fe845d21 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Thu, 16 Mar 2023 00:04:24 +0100 Subject: [PATCH 038/131] More scenarios in winget output fixed --- .../functions/Get-WingetOutdatedApps.ps1 | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 b/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 index 53cc0a7..41524ea 100644 --- a/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 +++ b/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 @@ -17,7 +17,7 @@ function Get-WingetOutdatedApps { } #Split winget output to lines - $lines = $upgradeResult.Split([Environment]::NewLine) | Where-Object { $_ -and $_ -notmatch "--include-unknown" } + $lines = $upgradeResult.Split([Environment]::NewLine) | Where-Object { $_ -and ($_ -notmatch "--include-unknown") -and ($_ -notmatch "update the source:") -and ($_ -notmatch "require explicit targeting") -and ($_ -notmatch "^(\d*)\s+(upgrade\w*)\s+(available\.)$") } # Find the line that starts with "------" $fl = 0 @@ -38,9 +38,16 @@ function Get-WingetOutdatedApps { # Now cycle in real package and split accordingly $upgradeList = @() - For ($i = $fl + 2; $i -lt $lines.Length - 1; $i++) { + For ($i = $fl + 2; $i -lt $lines.Length; $i++) { $line = $lines[$i] - if ($line) { + if ($line -and $line -match "^(Name)\s+(Id)\s+(Version)\s+(Available)$") { + #Get header titles + $index = $lines[$fl] -split '\s+' + $idStart = $lines[$i].IndexOf($index[1]) + $versionStart = $lines[$i].IndexOf($index[2]) + $availableStart = $lines[$i].IndexOf($index[3]) + } + if ($line -and ($line -notmatch "^(Name)\s+(Id)\s+(Version)\s+(Available)$") -and (-not $line.StartsWith("-----"))) { $software = [Software]::new() $software.Name = $line.Substring(0, $idStart).TrimEnd() $software.Id = $line.Substring($idStart, $versionStart - $idStart).TrimEnd() From 24aa53184d17739163b4a575bc4857063edec17f Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Thu, 16 Mar 2023 00:21:57 +0100 Subject: [PATCH 039/131] Forgon an $i --- Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 b/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 index 41524ea..04104b3 100644 --- a/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 +++ b/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 @@ -42,7 +42,7 @@ function Get-WingetOutdatedApps { $line = $lines[$i] if ($line -and $line -match "^(Name)\s+(Id)\s+(Version)\s+(Available)$") { #Get header titles - $index = $lines[$fl] -split '\s+' + $index = $lines[$i] -split '\s+' $idStart = $lines[$i].IndexOf($index[1]) $versionStart = $lines[$i].IndexOf($index[2]) $availableStart = $lines[$i].IndexOf($index[3]) From 1fcd0dccb4ee54a28fb3b280da560f7c77e737f1 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Fri, 17 Mar 2023 20:57:08 +0100 Subject: [PATCH 040/131] Language independent --- .../functions/Get-WingetOutdatedApps.ps1 | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 b/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 index 04104b3..7fff94c 100644 --- a/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 +++ b/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 @@ -17,7 +17,7 @@ function Get-WingetOutdatedApps { } #Split winget output to lines - $lines = $upgradeResult.Split([Environment]::NewLine) | Where-Object { $_ -and ($_ -notmatch "--include-unknown") -and ($_ -notmatch "update the source:") -and ($_ -notmatch "require explicit targeting") -and ($_ -notmatch "^(\d*)\s+(upgrade\w*)\s+(available\.)$") } + $lines = $upgradeResult.Split([Environment]::NewLine) | Where-Object { $_ } # Find the line that starts with "------" $fl = 0 @@ -40,14 +40,20 @@ function Get-WingetOutdatedApps { $upgradeList = @() For ($i = $fl + 2; $i -lt $lines.Length; $i++) { $line = $lines[$i] - if ($line -and $line -match "^(Name)\s+(Id)\s+(Version)\s+(Available)$") { + if ($line -and $line.StartsWith("-----")) { + #Get header line + $fl = $i - 1 + #Get header titles - $index = $lines[$i] -split '\s+' - $idStart = $lines[$i].IndexOf($index[1]) - $versionStart = $lines[$i].IndexOf($index[2]) - $availableStart = $lines[$i].IndexOf($index[3]) - } - if ($line -and ($line -notmatch "^(Name)\s+(Id)\s+(Version)\s+(Available)$") -and (-not $line.StartsWith("-----"))) { + $index = $lines[$fl] -split '\s+' + + # Line $fl has the header, we can find char where we find ID and Version + $idStart = $lines[$fl].IndexOf($index[1]) + $versionStart = $lines[$fl].IndexOf($index[2]) + $availableStart = $lines[$fl].IndexOf($index[3]) + } + #(Alphanumeric Literal . Alphanumeric) - the only thing in common for lines with applications + if ($line -and ($line -match "\w\.\w")) { $software = [Software]::new() $software.Name = $line.Substring(0, $idStart).TrimEnd() $software.Id = $line.Substring($idStart, $versionStart - $idStart).TrimEnd() From 1374b720f0006a38eab5a7c1cf1f1d9ad509f5a6 Mon Sep 17 00:00:00 2001 From: Matteo Cerri Date: Sat, 18 Mar 2023 00:06:29 +0100 Subject: [PATCH 041/131] Check actual language instead of region "Get-Culture" returns system region, while "Get-UICulture" returns the actual Windows display language. --- Winget-AutoUpdate/functions/Get-NotifLocale.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Winget-AutoUpdate/functions/Get-NotifLocale.ps1 b/Winget-AutoUpdate/functions/Get-NotifLocale.ps1 index fb481e7..69f0c53 100644 --- a/Winget-AutoUpdate/functions/Get-NotifLocale.ps1 +++ b/Winget-AutoUpdate/functions/Get-NotifLocale.ps1 @@ -3,7 +3,7 @@ Function Get-NotifLocale { #Get OS locale - $OSLocale = (Get-Culture).Parent + $OSLocale = (Get-UICulture).Parent #Test if OS locale notif file exists $TestOSLocalPath = "$WorkingDir\locale\$($OSLocale.Name).xml" From 9c7943d26d0a7575992ba78bf759670dae51b203 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sat, 18 Mar 2023 10:30:04 +0100 Subject: [PATCH 042/131] unique description --- Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 b/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 index 7fff94c..b06cb59 100644 --- a/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 +++ b/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 @@ -52,7 +52,7 @@ function Get-WingetOutdatedApps { $versionStart = $lines[$fl].IndexOf($index[2]) $availableStart = $lines[$fl].IndexOf($index[3]) } - #(Alphanumeric Literal . Alphanumeric) - the only thing in common for lines with applications + #(Alphanumeric | Literal . | Alphanumeric) - the only unique thing in common for lines with applications if ($line -and ($line -match "\w\.\w")) { $software = [Software]::new() $software.Name = $line.Substring(0, $idStart).TrimEnd() From 4be13794cb24e63a99f59d661b4a2f488b2d2b3f Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Sat, 18 Mar 2023 11:15:33 +0100 Subject: [PATCH 043/131] Update CloseInactiveIssues.yml --- .github/workflows/CloseInactiveIssues.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/CloseInactiveIssues.yml b/.github/workflows/CloseInactiveIssues.yml index a529a5c..593db14 100644 --- a/.github/workflows/CloseInactiveIssues.yml +++ b/.github/workflows/CloseInactiveIssues.yml @@ -3,6 +3,8 @@ on: schedule: - cron: "30 1 * * *" +permissions: read-all + jobs: close-issues: runs-on: ubuntu-latest From f9e786f7038e7f21fd276e110b17d26ba819e4a5 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sun, 19 Mar 2023 10:44:52 +0100 Subject: [PATCH 044/131] Final --- Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 b/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 index b06cb59..d0e861b 100644 --- a/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 +++ b/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 @@ -40,7 +40,7 @@ function Get-WingetOutdatedApps { $upgradeList = @() For ($i = $fl + 2; $i -lt $lines.Length; $i++) { $line = $lines[$i] - if ($line -and $line.StartsWith("-----")) { + if ($line.StartsWith("-----")) { #Get header line $fl = $i - 1 @@ -53,7 +53,7 @@ function Get-WingetOutdatedApps { $availableStart = $lines[$fl].IndexOf($index[3]) } #(Alphanumeric | Literal . | Alphanumeric) - the only unique thing in common for lines with applications - if ($line -and ($line -match "\w\.\w")) { + if ($line -match "\w\.\w") { $software = [Software]::new() $software.Name = $line.Substring(0, $idStart).TrimEnd() $software.Id = $line.Substring($idStart, $versionStart - $idStart).TrimEnd() From 4f7a42d95ba4b7653547ca30d255d2c98aa6880c Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Mon, 20 Mar 2023 12:15:51 +0100 Subject: [PATCH 045/131] v1.17.1 --- Winget-AutoUpdate-Install.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Winget-AutoUpdate-Install.ps1 b/Winget-AutoUpdate-Install.ps1 index c6f1c15..a168716 100644 --- a/Winget-AutoUpdate-Install.ps1 +++ b/Winget-AutoUpdate-Install.ps1 @@ -117,7 +117,7 @@ param( <# APP INFO #> -$WAUVersion = "1.17.0" +$WAUVersion = "1.17.1" <# FUNCTIONS #> From 9e4d23fe382021d519a6662a06eec52d68867017 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sat, 25 Mar 2023 06:00:07 +0100 Subject: [PATCH 046/131] [Bug]: Winget-AutoUpdate Parameter "ListPath" URL Not Pulling #304 --- Winget-AutoUpdate/functions/Test-ListPath.ps1 | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Winget-AutoUpdate/functions/Test-ListPath.ps1 b/Winget-AutoUpdate/functions/Test-ListPath.ps1 index 9284eeb..7711a78 100644 --- a/Winget-AutoUpdate/functions/Test-ListPath.ps1 +++ b/Winget-AutoUpdate/functions/Test-ListPath.ps1 @@ -37,8 +37,21 @@ function Test-ListPath ($ListPath, $UseWhiteList, $WingetUpdatePath) { } } catch { - $Script:ReachNoPath = $True - return $False + try { + $content = $wc.DownloadString("$ExternalList") + if ($null -ne $content -and $content) { + $wc.DownloadFile($ExternalList, $LocalList) + return $true + } + else { + $Script:ReachNoPath = $True + return $False + } + } + catch { + $Script:ReachNoPath = $True + return $False + } } } # If path is UNC or local From 553d97b1d7150b05f763e498d0a47d5dd4b2a495 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sat, 25 Mar 2023 06:23:20 +0100 Subject: [PATCH 047/131] Readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index fabd11c..18ed143 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,7 @@ Use White List instead of Black List. This setting will not create the "excluded **-ListPath** Get Black/White List from external Path (**URL/UNC/Local/GPO**) - download/copy to Winget-AutoUpdate installation location if external list is newer. **PATH** must end with a Directory, not a File... +...if the external Path is an **URL** and the web host doesn't respond with a date/time header for the file (i.e **GitHub**) then the file is always downloaded! If `-ListPath` is set to **GPO** the Black/White List can be managed from within the GPO itself under **Application GPO Blacklist**/**Application GPO Whitelist**. Thanks to [Weatherlights](https://github.com/Weatherlights) in [#256 (reply in thread)](https://github.com/Romanitho/Winget-AutoUpdate/discussions/256#discussioncomment-4710599)! From 43a176a99fd286b5e97057dd5355bc5d3e89e4a9 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sat, 25 Mar 2023 20:12:51 +0100 Subject: [PATCH 048/131] -UseBasicParsing --- Winget-AutoUpdate-Install.ps1 | 2 +- Winget-AutoUpdate/functions/Get-AZCopy.ps1 | 4 ++-- Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Winget-AutoUpdate-Install.ps1 b/Winget-AutoUpdate-Install.ps1 index a168716..2543eb8 100644 --- a/Winget-AutoUpdate-Install.ps1 +++ b/Winget-AutoUpdate-Install.ps1 @@ -162,7 +162,7 @@ function Install-Prerequisites { $SourceURL = "https://aka.ms/vs/17/release/VC_redist.$OSArch.exe" $Installer = $WingetUpdatePath + "\VC_redist.$OSArch.exe" $ProgressPreference = 'SilentlyContinue' - Invoke-WebRequest $SourceURL -OutFile (New-Item -Path $Installer -Force) + Invoke-WebRequest $SourceURL -UseBasicParsing -OutFile (New-Item -Path $Installer -Force) Write-host "-> Installing VC_redist.$OSArch.exe..." Start-Process -FilePath $Installer -Args "/quiet /norestart" -Wait Remove-Item $Installer -ErrorAction Ignore diff --git a/Winget-AutoUpdate/functions/Get-AZCopy.ps1 b/Winget-AutoUpdate/functions/Get-AZCopy.ps1 index bfe7994..d960709 100644 --- a/Winget-AutoUpdate/functions/Get-AZCopy.ps1 +++ b/Winget-AutoUpdate/functions/Get-AZCopy.ps1 @@ -2,7 +2,7 @@ Function Get-AZCopy ($WingetUpdatePath){ - $AZCopyLink = (Invoke-WebRequest -Uri https://aka.ms/downloadazcopy-v10-windows -MaximumRedirection 0 -ErrorAction SilentlyContinue).headers.location + $AZCopyLink = (Invoke-WebRequest -Uri https://aka.ms/downloadazcopy-v10-windows -UseBasicParsing -MaximumRedirection 0 -ErrorAction SilentlyContinue).headers.location $AZCopyVersionRegex = [regex]::new("(\d+\.\d+\.\d+)") $AZCopyLatestVersion = $AZCopyVersionRegex.Match($AZCopyLink).Value @@ -22,7 +22,7 @@ Function Get-AZCopy ($WingetUpdatePath){ if (([version] $AZCopyCurrentVersion) -lt ([version] $AZCopyLatestVersion)) { Write-Log "Installing version $AZCopyLatestVersion of AZCopy" - Invoke-WebRequest -Uri $AZCopyLink -OutFile "$WingetUpdatePath\azcopyv10.zip" + Invoke-WebRequest -Uri $AZCopyLink -UseBasicParsing -OutFile "$WingetUpdatePath\azcopyv10.zip" Write-Log "Extracting AZCopy zip file" Expand-archive -Path "$WingetUpdatePath\azcopyv10.zip" -Destinationpath "$WingetUpdatePath" -Force diff --git a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 index f1d314d..6b54125 100644 --- a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 +++ b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 @@ -31,7 +31,7 @@ function Invoke-PostUpdateActions { $SourceURL = "https://aka.ms/vs/17/release/VC_redist.$OSArch.exe" $Installer = "$($WAUConfig.InstallLocation)\VC_redist.$OSArch.exe" $ProgressPreference = 'SilentlyContinue' - Invoke-WebRequest $SourceURL -OutFile (New-Item -Path $Installer -Force) + Invoke-WebRequest $SourceURL -UseBasicParsing -OutFile (New-Item -Path $Installer -Force) Write-Log "-> Installing VC_redist.$OSArch.exe..." Start-Process -FilePath $Installer -Args "/quiet /norestart" -Wait Remove-Item $Installer -ErrorAction Ignore From 9d52edaea1e164bb13705b76b4c8f93983caa295 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Mar 2023 07:14:43 +0000 Subject: [PATCH 049/131] Bump actions/stale from 7 to 8 Bumps [actions/stale](https://github.com/actions/stale) from 7 to 8. - [Release notes](https://github.com/actions/stale/releases) - [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/stale/compare/v7...v8) --- updated-dependencies: - dependency-name: actions/stale dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/CloseInactiveIssues.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CloseInactiveIssues.yml b/.github/workflows/CloseInactiveIssues.yml index 593db14..d86e255 100644 --- a/.github/workflows/CloseInactiveIssues.yml +++ b/.github/workflows/CloseInactiveIssues.yml @@ -12,7 +12,7 @@ jobs: issues: write pull-requests: write steps: - - uses: actions/stale@v7 + - uses: actions/stale@v8 with: days-before-issue-stale: 30 days-before-issue-close: 14 From d8e526f23824bb753a4f1845d9f21fc2cdd34d68 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Tue, 28 Mar 2023 10:22:43 +0200 Subject: [PATCH 050/131] Test content for winget ID:s --- Winget-AutoUpdate/functions/Test-ListPath.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Winget-AutoUpdate/functions/Test-ListPath.ps1 b/Winget-AutoUpdate/functions/Test-ListPath.ps1 index 7711a78..f9a8fe6 100644 --- a/Winget-AutoUpdate/functions/Test-ListPath.ps1 +++ b/Winget-AutoUpdate/functions/Test-ListPath.ps1 @@ -39,7 +39,7 @@ function Test-ListPath ($ListPath, $UseWhiteList, $WingetUpdatePath) { catch { try { $content = $wc.DownloadString("$ExternalList") - if ($null -ne $content -and $content) { + if ($null -ne $content -and $content -match "\w\.\w") { $wc.DownloadFile($ExternalList, $LocalList) return $true } From 1e318f6668536505ac4ee72726dc70afcb68fbe3 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Tue, 28 Mar 2023 13:14:50 +0200 Subject: [PATCH 051/131] v1.17.2 --- Winget-AutoUpdate-Install.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Winget-AutoUpdate-Install.ps1 b/Winget-AutoUpdate-Install.ps1 index 2543eb8..7167a43 100644 --- a/Winget-AutoUpdate-Install.ps1 +++ b/Winget-AutoUpdate-Install.ps1 @@ -117,7 +117,7 @@ param( <# APP INFO #> -$WAUVersion = "1.17.1" +$WAUVersion = "1.17.2" <# FUNCTIONS #> From 9b01832750de923d850e541bc94fa0cba467e2ef Mon Sep 17 00:00:00 2001 From: Fabian Seitz Date: Thu, 30 Mar 2023 11:30:55 +0200 Subject: [PATCH 052/131] New workflow to check WAU installation and first run --- .github/workflows/powershell-tests.yaml | 61 +++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .github/workflows/powershell-tests.yaml diff --git a/.github/workflows/powershell-tests.yaml b/.github/workflows/powershell-tests.yaml new file mode 100644 index 0000000..8c6bef0 --- /dev/null +++ b/.github/workflows/powershell-tests.yaml @@ -0,0 +1,61 @@ +name: WAU PS Test + +# yamllint disable-line rule:truthy +on: + push: + pull_request: + types: + - opened + - reopened + - synchronize + workflow_dispatch: + +permissions: + contents: read + pull-requests: read + +jobs: + powershell-tests: + name: Pester test and PSScriptAnalyzer + runs-on: windows-latest + steps: + - name: Check out repository code + uses: actions/checkout@v3 + - name: Perform a Pester test for the WAU installation + shell: powershell + run: | + $command = New-PesterContainer -Path Winget-AutoUpdate-Install.ps1 -Data @{ Silent = $true } + Invoke-Pester -PassThru -Container $command -ErrorAction Continue + - name: Perform a Pester test for WAU run + shell: powershell + run: | + $command = New-PesterContainer -Path C:\ProgramData\Winget-AutoUpdate\user-run.ps1 + Invoke-Pester -PassThru -Container $command -ErrorAction Continue + #- name: Read WAU Log + # id: package + # uses: juliangruber/read-file-action@v1 + # with: + # path: 'C:\ProgramData\Winget-AutoUpdate\Logs\updates.log' + #- name: Display WAU Log + # run: type "${{ steps.package.outputs.content }}" + - name: Install PSScriptAnalyzer module from PSGallery + shell: powershell + run: | + Set-PSRepository PSGallery -InstallationPolicy Trusted + Install-Module PSScriptAnalyzer -ErrorAction Stop + - name: Lint with PSScriptAnalyzer + shell: powershell + run: | + Invoke-ScriptAnalyzer -Path *.ps1 -Recurse -Outvariable issues + $errors = $issues.Where({$_.Severity -eq 'Error'}) + $warnings = $issues.Where({$_.Severity -eq 'Warning'}) + if ($($errors.Count) -gt 0) { + $ErrorAction = "Stop" + } else { + $ErrorAction = "Continue" + } + if ($errors) { + Write-Error "There were $($errors.Count) errors and $($warnings.Count) warnings total." -ErrorAction $ErrorAction + } else { + Write-Output "There were $($errors.Count) errors and $($warnings.Count) warnings total." + } From fe6857b1729dc888111af26cd6cf769b22c46f83 Mon Sep 17 00:00:00 2001 From: Fabian Seitz Date: Fri, 31 Mar 2023 14:53:21 +0200 Subject: [PATCH 053/131] Switch to oxsecurity/megalinter --- .github/workflows/mega-linter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mega-linter.yml b/.github/workflows/mega-linter.yml index 16904e2..a26541b 100644 --- a/.github/workflows/mega-linter.yml +++ b/.github/workflows/mega-linter.yml @@ -41,7 +41,7 @@ jobs: id: ml # You can override MegaLinter flavor used to have faster performances # More info at https://megalinter.github.io/flavors/ - uses: megalinter/megalinter@v6 + uses: oxsecurity/megalinter@v6 env: # All available variables are described in documentation # https://megalinter.github.io/configuration/ From c23f3d68835999d3b44bb176f1fd1a89eb2e5547 Mon Sep 17 00:00:00 2001 From: Fabian Seitz Date: Fri, 31 Mar 2023 17:56:07 +0200 Subject: [PATCH 054/131] Small optical code improvements --- Winget-AutoUpdate-Install.ps1 | 6 +- Winget-AutoUpdate/User-Run.ps1 | 2 +- Winget-AutoUpdate/WAU-Uninstall.ps1 | 2 +- Winget-AutoUpdate/Winget-Notify.ps1 | 2 +- Winget-AutoUpdate/Winget-Upgrade.ps1 | 16 ++--- .../functions/Add-ScopeMachine.ps1 | 2 +- Winget-AutoUpdate/functions/Add-Shortcut.ps1 | 2 +- Winget-AutoUpdate/functions/Get-AZCopy.ps1 | 16 ++--- Winget-AutoUpdate/functions/Get-AppInfo.ps1 | 2 +- .../functions/Get-ExcludedApps.ps1 | 12 ++-- .../functions/Get-IncludedApps.ps1 | 8 +-- .../functions/Get-NotifLocale.ps1 | 2 +- Winget-AutoUpdate/functions/Get-Policies.ps1 | 72 +++++++++---------- .../functions/Get-WAUAvailableVersion.ps1 | 2 +- Winget-AutoUpdate/functions/Get-WingetCmd.ps1 | 2 +- .../functions/Get-WingetOutdatedApps.ps1 | 6 +- .../functions/Get-WingetSystemApps.ps1 | 2 +- .../functions/Invoke-LogRotation.ps1 | 2 +- .../functions/Invoke-ModsProtect.ps1 | 24 +++---- .../functions/Invoke-PostUpdateActions.ps1 | 4 +- Winget-AutoUpdate/functions/Start-Init.ps1 | 2 +- .../functions/Start-NotifTask.ps1 | 14 ++-- Winget-AutoUpdate/functions/Test-ListPath.ps1 | 2 +- Winget-AutoUpdate/functions/Test-Mods.ps1 | 2 +- Winget-AutoUpdate/functions/Test-ModsPath.ps1 | 54 +++++++------- Winget-AutoUpdate/functions/Test-Network.ps1 | 2 +- .../functions/Test-PendingReboot.ps1 | 2 +- Winget-AutoUpdate/functions/Update-App.ps1 | 14 ++-- Winget-AutoUpdate/functions/Update-WAU.ps1 | 2 +- Winget-AutoUpdate/functions/Write-Log.ps1 | 2 +- Winget-AutoUpdate/mods/_AppID-template.ps1 | 2 +- Winget-AutoUpdate/mods/_Mods-Functions.ps1 | 60 +++++++--------- 32 files changed, 167 insertions(+), 177 deletions(-) diff --git a/Winget-AutoUpdate-Install.ps1 b/Winget-AutoUpdate-Install.ps1 index 7167a43..c34d868 100644 --- a/Winget-AutoUpdate-Install.ps1 +++ b/Winget-AutoUpdate-Install.ps1 @@ -4,7 +4,7 @@ Configure Winget to daily update installed apps. .DESCRIPTION Install powershell scripts and scheduled task to daily run Winget upgrade and notify connected users. -Possible to exclude apps from auto-update +Posibility to exclude apps from auto-update https://github.com/Romanitho/Winget-AutoUpdate .PARAMETER Silent @@ -111,7 +111,7 @@ param( [Parameter(Mandatory = $False)] [DateTime] $UpdatesAtTime = ("06am"), [Parameter(Mandatory = $False)] [Switch] $BypassListForUsers = $false, [Parameter(Mandatory = $False)] [Switch] $InstallUserContext = $false, - [Parameter(Mandatory = $False)] [ValidateRange(0,99)] [int32] $MaxLogFiles = 3, + [Parameter(Mandatory = $False)] [ValidateRange(0, 99)] [int32] $MaxLogFiles = 3, [Parameter(Mandatory = $False)] [int64] $MaxLogSize = 1048576 # in bytes, default is 1048576 = 1 MB ) @@ -391,7 +391,7 @@ function Install-WingetAutoUpdate { else { Write-Host "Error: The mods directory couldn't be verified as secured!`n" -ForegroundColor Red } - + #Create Shortcuts if ($StartMenuShortcut) { if (!(Test-Path "${env:ProgramData}\Microsoft\Windows\Start Menu\Programs\Winget-AutoUpdate (WAU)")) { diff --git a/Winget-AutoUpdate/User-Run.ps1 b/Winget-AutoUpdate/User-Run.ps1 index f60560f..13e0974 100644 --- a/Winget-AutoUpdate/User-Run.ps1 +++ b/Winget-AutoUpdate/User-Run.ps1 @@ -1,6 +1,6 @@ <# .SYNOPSIS -Handle user interaction from shortcuts and show a Toast +Handle user interaction from shortcuts and show a Toast notification .DESCRIPTION Act on shortcut run (DEFAULT: Check for updated Apps) diff --git a/Winget-AutoUpdate/WAU-Uninstall.ps1 b/Winget-AutoUpdate/WAU-Uninstall.ps1 index 7590e47..a90bda7 100644 --- a/Winget-AutoUpdate/WAU-Uninstall.ps1 +++ b/Winget-AutoUpdate/WAU-Uninstall.ps1 @@ -3,7 +3,7 @@ Uninstall Winget-AutoUpdate .DESCRIPTION -Uninstall Winget-AutoUpdate (DEFAULT: clean old install) +Uninstalls Winget-AutoUpdate (DEFAULT: clean old install) https://github.com/Romanitho/Winget-AutoUpdate .PARAMETER NoClean diff --git a/Winget-AutoUpdate/Winget-Notify.ps1 b/Winget-AutoUpdate/Winget-Notify.ps1 index d4a90c2..de22ef7 100644 --- a/Winget-AutoUpdate/Winget-Notify.ps1 +++ b/Winget-AutoUpdate/Winget-Notify.ps1 @@ -1,4 +1,4 @@ -#Send Notif Script +#Send Notify Script #get xml notif config $WAUinstalledPath = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocation diff --git a/Winget-AutoUpdate/Winget-Upgrade.ps1 b/Winget-AutoUpdate/Winget-Upgrade.ps1 index c0d2fd5..9bede9d 100644 --- a/Winget-AutoUpdate/Winget-Upgrade.ps1 +++ b/Winget-AutoUpdate/Winget-Upgrade.ps1 @@ -1,6 +1,6 @@ <# LOAD FUNCTIONS #> -#Get Working Dir +#Get the Working Dir $Script:WorkingDir = $PSScriptRoot #Get Functions Get-ChildItem "$WorkingDir\functions" | ForEach-Object { . $_.FullName } @@ -41,7 +41,7 @@ if ($IsSystem) { else { [int32] $MaxLogFiles = $MaxLogFiles } - + # Maximum size of log file. $MaxLogSize = $WAUConfig.WAU_MaxLogSize if (!$MaxLogSize) { @@ -147,7 +147,7 @@ if (Test-Network) { } } } - + #Get External ModsPath if run as System if ($WAUConfig.WAU_ModsPath) { $ModsPathClean = $($WAUConfig.WAU_ModsPath.TrimEnd(" ", "\", "/")) @@ -289,12 +289,10 @@ if (Test-Network) { if ($IsSystem) { #User check routine from: https://stackoverflow.com/questions/23219718/powershell-script-to-see-currently-logged-in-users-domain-and-machine-status $explorerprocesses = @(Get-WmiObject -Query "Select * FROM Win32_Process WHERE Name='explorer.exe'" -ErrorAction SilentlyContinue) - If ($explorerprocesses.Count -eq 0) - { + If ($explorerprocesses.Count -eq 0) { Write-Log "No explorer process found / Nobody interactively logged on..." } - Else - { + Else { #Run WAU in user context if the user task exist $UserScheduledTask = Get-ScheduledTask -TaskName "Winget-AutoUpdate-UserContext" -ErrorAction SilentlyContinue if ($UserScheduledTask) { @@ -308,10 +306,10 @@ if (Test-Network) { Start-ScheduledTask $UserScheduledTask.TaskName -ErrorAction SilentlyContinue Exit 0 } - elseif (!$UserScheduledTask){ + elseif (!$UserScheduledTask) { Write-Log "User context execution not installed..." } - } + } } } else { diff --git a/Winget-AutoUpdate/functions/Add-ScopeMachine.ps1 b/Winget-AutoUpdate/functions/Add-ScopeMachine.ps1 index dfdb145..44bb7e4 100644 --- a/Winget-AutoUpdate/functions/Add-ScopeMachine.ps1 +++ b/Winget-AutoUpdate/functions/Add-ScopeMachine.ps1 @@ -1,4 +1,4 @@ -#Function to configure prefered scope option as Machine +#Function to configure the prefered scope option as Machine function Add-ScopeMachine ($SettingsPath) { if (Test-Path $SettingsPath) { diff --git a/Winget-AutoUpdate/functions/Add-Shortcut.ps1 b/Winget-AutoUpdate/functions/Add-Shortcut.ps1 index 3feb396..98b6e77 100644 --- a/Winget-AutoUpdate/functions/Add-Shortcut.ps1 +++ b/Winget-AutoUpdate/functions/Add-Shortcut.ps1 @@ -1,4 +1,4 @@ -#Function for creating shortcuts +#Function to create shortcuts function Add-Shortcut ($Target, $Shortcut, $Arguments, $Icon, $Description) { $WScriptShell = New-Object -ComObject WScript.Shell $Shortcut = $WScriptShell.CreateShortcut($Shortcut) diff --git a/Winget-AutoUpdate/functions/Get-AZCopy.ps1 b/Winget-AutoUpdate/functions/Get-AZCopy.ps1 index d960709..7926291 100644 --- a/Winget-AutoUpdate/functions/Get-AZCopy.ps1 +++ b/Winget-AutoUpdate/functions/Get-AZCopy.ps1 @@ -1,6 +1,6 @@ -#Function to get AZCopy if it doesn't exist and update it if it does +#Function to get AZCopy, if it doesn't exist and update it, if it does -Function Get-AZCopy ($WingetUpdatePath){ +Function Get-AZCopy ($WingetUpdatePath) { $AZCopyLink = (Invoke-WebRequest -Uri https://aka.ms/downloadazcopy-v10-windows -UseBasicParsing -MaximumRedirection 0 -ErrorAction SilentlyContinue).headers.location $AZCopyVersionRegex = [regex]::new("(\d+\.\d+\.\d+)") @@ -12,23 +12,23 @@ Function Get-AZCopy ($WingetUpdatePath){ if (Test-Path -Path "$WingetUpdatePath\azcopy.exe" -PathType Leaf) { $AZCopyCurrentVersion = & "$WingetUpdatePath\azcopy.exe" -v - $AZCopyCurrentVersion = $AZCopyVersionRegex.Match($AZCopyCurrentVersion).Value - Write-Log "AZCopy version $AZCopyCurrentVersion found" + $AZCopyCurrentVersion = $AZCopyVersionRegex.Match($AZCopyCurrentVersion).Value + Write-Log "AZCopy version $AZCopyCurrentVersion found" } else { - Write-Log "AZCopy not already installed" + Write-Log "AZCopy not already installed" $AZCopyCurrentVersion = "0.0.0" } if (([version] $AZCopyCurrentVersion) -lt ([version] $AZCopyLatestVersion)) { - Write-Log "Installing version $AZCopyLatestVersion of AZCopy" + Write-Log "Installing version $AZCopyLatestVersion of AZCopy" Invoke-WebRequest -Uri $AZCopyLink -UseBasicParsing -OutFile "$WingetUpdatePath\azcopyv10.zip" Write-Log "Extracting AZCopy zip file" Expand-archive -Path "$WingetUpdatePath\azcopyv10.zip" -Destinationpath "$WingetUpdatePath" -Force - $AZCopyPathSearch = Resolve-Path -path "$WingetUpdatePath\azcopy_*" - + $AZCopyPathSearch = Resolve-Path -path "$WingetUpdatePath\azcopy_*" + if ($AZCopyPathSearch -is [array]) { $AZCopyEXEPath = $AZCopyPathSearch[$AZCopyPathSearch.Length - 1] } diff --git a/Winget-AutoUpdate/functions/Get-AppInfo.ps1 b/Winget-AutoUpdate/functions/Get-AppInfo.ps1 index 62a45f2..747a818 100644 --- a/Winget-AutoUpdate/functions/Get-AppInfo.ps1 +++ b/Winget-AutoUpdate/functions/Get-AppInfo.ps1 @@ -1,4 +1,4 @@ -#Get App Info +#Get the winget App Information Function Get-AppInfo ($AppID) { #Get AppID Info diff --git a/Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 b/Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 index ff6878a..0212e5c 100644 --- a/Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 +++ b/Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 @@ -1,26 +1,26 @@ -#Function to get Black List apps +#Function to get the Block List apps function Get-ExcludedApps { if ($GPOList) { - + if (Test-Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\BlackList") { $Key = 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\BlackList\' $ValueNames = (Get-Item -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\BlackList").Property - + foreach ($ValueName in $ValueNames) { $AppIDs = [Microsoft.Win32.Registry]::GetValue($Key, $ValueName, $false) [PSCustomObject]@{ Value = $ValueName - Data = $AppIDs.Trim() + Data = $AppIDs.Trim() } } - + } return $AppIDs - + } elseif (Test-Path "$WorkingDir\excluded_apps.txt") { diff --git a/Winget-AutoUpdate/functions/Get-IncludedApps.ps1 b/Winget-AutoUpdate/functions/Get-IncludedApps.ps1 index c4cb053..ae2a8ad 100644 --- a/Winget-AutoUpdate/functions/Get-IncludedApps.ps1 +++ b/Winget-AutoUpdate/functions/Get-IncludedApps.ps1 @@ -1,4 +1,4 @@ -#Function to get White List apps +#Function to get the allow List apps function Get-IncludedApps { @@ -9,15 +9,15 @@ function Get-IncludedApps { $Key = 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\WhiteList\' $ValueNames = (Get-Item -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\WhiteList").Property - + foreach ($ValueName in $ValueNames) { $AppIDs = [Microsoft.Win32.Registry]::GetValue($Key, $ValueName, $false) [PSCustomObject]@{ Value = $ValueName - Data = $AppIDs.Trim() + Data = $AppIDs.Trim() } } - + } return $AppIDs diff --git a/Winget-AutoUpdate/functions/Get-NotifLocale.ps1 b/Winget-AutoUpdate/functions/Get-NotifLocale.ps1 index 69f0c53..f0bd3a2 100644 --- a/Winget-AutoUpdate/functions/Get-NotifLocale.ps1 +++ b/Winget-AutoUpdate/functions/Get-NotifLocale.ps1 @@ -1,4 +1,4 @@ -#Function to get locale file for Notification. +#Function to get the locale file for notifications Function Get-NotifLocale { diff --git a/Winget-AutoUpdate/functions/Get-Policies.ps1 b/Winget-AutoUpdate/functions/Get-Policies.ps1 index bad0ee1..0200341 100644 --- a/Winget-AutoUpdate/functions/Get-Policies.ps1 +++ b/Winget-AutoUpdate/functions/Get-Policies.ps1 @@ -1,4 +1,4 @@ -#Function to get Domain/Local Policies (GPO) +#Function to get the Domain/Local Policies (GPO) Function Get-Policies { #Get WAU Policies and set the Configurations Registry Accordingly @@ -15,7 +15,7 @@ Function Get-Policies { Remove-ItemProperty $regPath -Name WAU_BypassListForUsers -Force -ErrorAction SilentlyContinue | Out-Null $ChangedSettings++ } - + if ($null -ne $($WAUPolicies.WAU_DisableAutoUpdate) -and ($($WAUPolicies.WAU_DisableAutoUpdate) -ne $($WAUConfig.WAU_DisableAutoUpdate))) { New-ItemProperty $regPath -Name WAU_DisableAutoUpdate -Value $($WAUPolicies.WAU_DisableAutoUpdate) -PropertyType DWord -Force | Out-Null $ChangedSettings++ @@ -24,7 +24,7 @@ Function Get-Policies { Remove-ItemProperty $regPath -Name WAU_DisableAutoUpdate -Force -ErrorAction SilentlyContinue | Out-Null $ChangedSettings++ } - + if ($null -ne $($WAUPolicies.WAU_DoNotRunOnMetered) -and ($($WAUPolicies.WAU_DoNotRunOnMetered) -ne $($WAUConfig.WAU_DoNotRunOnMetered))) { New-ItemProperty $regPath -Name WAU_DoNotRunOnMetered -Value $($WAUPolicies.WAU_DoNotRunOnMetered) -PropertyType DWord -Force | Out-Null $ChangedSettings++ @@ -33,7 +33,7 @@ Function Get-Policies { New-ItemProperty $regPath -Name WAU_DoNotRunOnMetered -Value 1 -PropertyType DWord -Force | Out-Null $ChangedSettings++ } - + if ($null -ne $($WAUPolicies.WAU_UpdatePrerelease) -and ($($WAUPolicies.WAU_UpdatePrerelease) -ne $($WAUConfig.WAU_UpdatePrerelease))) { New-ItemProperty $regPath -Name WAU_UpdatePrerelease -Value $($WAUPolicies.WAU_UpdatePrerelease) -PropertyType DWord -Force | Out-Null $ChangedSettings++ @@ -42,7 +42,7 @@ Function Get-Policies { New-ItemProperty $regPath -Name WAU_UpdatePrerelease -Value 0 -PropertyType DWord -Force | Out-Null $ChangedSettings++ } - + if ($null -ne $($WAUPolicies.WAU_UseWhiteList) -and ($($WAUPolicies.WAU_UseWhiteList) -ne $($WAUConfig.WAU_UseWhiteList))) { New-ItemProperty $regPath -Name WAU_UseWhiteList -Value $($WAUPolicies.WAU_UseWhiteList) -PropertyType DWord -Force | Out-Null $ChangedSettings++ @@ -51,7 +51,7 @@ Function Get-Policies { Remove-ItemProperty $regPath -Name WAU_UseWhiteList -Force -ErrorAction SilentlyContinue | Out-Null $ChangedSettings++ } - + if ($null -ne $($WAUPolicies.WAU_ListPath) -and ($($WAUPolicies.WAU_ListPath) -ne $($WAUConfig.WAU_ListPath))) { New-ItemProperty $regPath -Name WAU_ListPath -Value $($WAUPolicies.WAU_ListPath.TrimEnd(" ", "\", "/")) -Force | Out-Null $ChangedSettings++ @@ -60,7 +60,7 @@ Function Get-Policies { Remove-ItemProperty $regPath -Name WAU_ListPath -Force -ErrorAction SilentlyContinue | Out-Null $ChangedSettings++ } - + if ($null -ne $($WAUPolicies.WAU_ModsPath) -and ($($WAUPolicies.WAU_ModsPath) -ne $($WAUConfig.WAU_ModsPath))) { New-ItemProperty $regPath -Name WAU_ModsPath -Value $($WAUPolicies.WAU_ModsPath.TrimEnd(" ", "\", "/")) -Force | Out-Null $ChangedSettings++ @@ -95,14 +95,14 @@ Function Get-Policies { $folder = $service.GetFolder('\') $task = $folder.GetTask("Winget-AutoUpdate") $definition = $task.Definition - for($triggerId=1; $triggerId -le $definition.Triggers.Count; $triggerId++){ - if(($definition.Triggers.Item($triggerId).Type -eq "2") -or ($definition.Triggers.Item($triggerId).Type -eq "3")){ - $PreStartBoundary = ($definition.Triggers.Item($triggerId).StartBoundary).Substring(0,11) - $PostStartBoundary = ($definition.Triggers.Item($triggerId).StartBoundary).Substring(19,6) + for ($triggerId = 1; $triggerId -le $definition.Triggers.Count; $triggerId++) { + if (($definition.Triggers.Item($triggerId).Type -eq "2") -or ($definition.Triggers.Item($triggerId).Type -eq "3")) { + $PreStartBoundary = ($definition.Triggers.Item($triggerId).StartBoundary).Substring(0, 11) + $PostStartBoundary = ($definition.Triggers.Item($triggerId).StartBoundary).Substring(19, 6) $Boundary = $PreStartBoundary + $($WAUPolicies.WAU_UpdatesAtTime) + $PostStartBoundary $definition.Triggers.Item($triggerId).StartBoundary = $Boundary break - $triggerId-=1 + $triggerId -= 1 } } $folder.RegisterTaskDefinition($task.Name, $definition, 4, $null, $null, $null) | Out-Null @@ -116,14 +116,14 @@ Function Get-Policies { $folder = $service.GetFolder('\') $task = $folder.GetTask("Winget-AutoUpdate") $definition = $task.Definition - for($triggerId=1; $triggerId -le $definition.Triggers.Count; $triggerId++){ - if(($definition.Triggers.Item($triggerId).Type -eq "2") -or ($definition.Triggers.Item($triggerId).Type -eq "3")){ - $PreStartBoundary = ($definition.Triggers.Item($triggerId).StartBoundary).Substring(0,11) - $PostStartBoundary = ($definition.Triggers.Item($triggerId).StartBoundary).Substring(19,6) + for ($triggerId = 1; $triggerId -le $definition.Triggers.Count; $triggerId++) { + if (($definition.Triggers.Item($triggerId).Type -eq "2") -or ($definition.Triggers.Item($triggerId).Type -eq "3")) { + $PreStartBoundary = ($definition.Triggers.Item($triggerId).StartBoundary).Substring(0, 11) + $PostStartBoundary = ($definition.Triggers.Item($triggerId).StartBoundary).Substring(19, 6) $Boundary = $PreStartBoundary + "06:00:00" + $PostStartBoundary $definition.Triggers.Item($triggerId).StartBoundary = $Boundary break - $triggerId-=1 + $triggerId -= 1 } } $folder.RegisterTaskDefinition($task.Name, $definition, 4, $null, $null, $null) | Out-Null @@ -137,11 +137,11 @@ Function Get-Policies { $folder = $service.GetFolder('\') $task = $folder.GetTask("Winget-AutoUpdate") $definition = $task.Definition - for($triggerId=1; $triggerId -le $definition.Triggers.Count; $triggerId++){ - if(($definition.Triggers.Item($triggerId).Type -eq "2") -or ($definition.Triggers.Item($triggerId).Type -eq "3")){ - $UpdatesAtTime = ($definition.Triggers.Item($triggerId).StartBoundary).Substring(11,8) + for ($triggerId = 1; $triggerId -le $definition.Triggers.Count; $triggerId++) { + if (($definition.Triggers.Item($triggerId).Type -eq "2") -or ($definition.Triggers.Item($triggerId).Type -eq "3")) { + $UpdatesAtTime = ($definition.Triggers.Item($triggerId).StartBoundary).Substring(11, 8) $definition.Triggers.Remove($triggerId) - $triggerId-=1 + $triggerId -= 1 } } $folder.RegisterTaskDefinition($task.Name, $definition, 4, $null, $null, $null) | Out-Null @@ -160,11 +160,11 @@ Function Get-Policies { $definition = $task.Definition $definition.Triggers.Count | Out-Null switch ($($WAUPolicies.WAU_UpdatesInterval)) { - "Daily" {$tasktrigger = New-ScheduledTaskTrigger -Daily -At $($WAUConfig.WAU_UpdatesAtTime); break} - "BiDaily" {$tasktrigger = New-ScheduledTaskTrigger -Daily -At $($WAUConfig.WAU_UpdatesAtTime) -DaysInterval 2; break} - "Weekly" {$tasktrigger = New-ScheduledTaskTrigger -Weekly -At $($WAUConfig.WAU_UpdatesAtTime) -DaysOfWeek 2; break} - "BiWeekly" {$tasktrigger = New-ScheduledTaskTrigger -Weekly -At $($WAUConfig.WAU_UpdatesAtTime) -DaysOfWeek 2 -WeeksInterval 2; break} - "Monthly" {$tasktrigger = New-ScheduledTaskTrigger -Weekly -At $($WAUConfig.WAU_UpdatesAtTime) -DaysOfWeek 2 -WeeksInterval 4; break} + "Daily" { $tasktrigger = New-ScheduledTaskTrigger -Daily -At $($WAUConfig.WAU_UpdatesAtTime); break } + "BiDaily" { $tasktrigger = New-ScheduledTaskTrigger -Daily -At $($WAUConfig.WAU_UpdatesAtTime) -DaysInterval 2; break } + "Weekly" { $tasktrigger = New-ScheduledTaskTrigger -Weekly -At $($WAUConfig.WAU_UpdatesAtTime) -DaysOfWeek 2; break } + "BiWeekly" { $tasktrigger = New-ScheduledTaskTrigger -Weekly -At $($WAUConfig.WAU_UpdatesAtTime) -DaysOfWeek 2 -WeeksInterval 2; break } + "Monthly" { $tasktrigger = New-ScheduledTaskTrigger -Weekly -At $($WAUConfig.WAU_UpdatesAtTime) -DaysOfWeek 2 -WeeksInterval 4; break } } if ($definition.Triggers.Count -gt 0) { $triggers = @() @@ -185,11 +185,11 @@ Function Get-Policies { $folder = $service.GetFolder('\') $task = $folder.GetTask("Winget-AutoUpdate") $definition = $task.Definition - for($triggerId=1; $triggerId -le $definition.Triggers.Count; $triggerId++){ - if(($definition.Triggers.Item($triggerId).Type -eq "2") -or ($definition.Triggers.Item($triggerId).Type -eq "3")){ - $UpdatesAtTime = ($definition.Triggers.Item($triggerId).StartBoundary).Substring(11,8) + for ($triggerId = 1; $triggerId -le $definition.Triggers.Count; $triggerId++) { + if (($definition.Triggers.Item($triggerId).Type -eq "2") -or ($definition.Triggers.Item($triggerId).Type -eq "3")) { + $UpdatesAtTime = ($definition.Triggers.Item($triggerId).StartBoundary).Substring(11, 8) $definition.Triggers.Remove($triggerId) - $triggerId-=1 + $triggerId -= 1 } } $folder.RegisterTaskDefinition($task.Name, $definition, 4, $null, $null, $null) | Out-Null @@ -251,10 +251,10 @@ Function Get-Policies { $task = $folder.GetTask("Winget-AutoUpdate") $definition = $task.Definition $definition.Triggers.Count | Out-Null - for($triggerId=1; $triggerId -le $definition.Triggers.Count; $triggerId++){ - if($definition.Triggers.Item($triggerId).Type -eq "9"){ + for ($triggerId = 1; $triggerId -le $definition.Triggers.Count; $triggerId++) { + if ($definition.Triggers.Item($triggerId).Type -eq "9") { $definition.Triggers.Remove($triggerId) - $triggerId-=1 + $triggerId -= 1 } } $folder.RegisterTaskDefinition($task.Name, $definition, 4, $null, $null, $null) | Out-Null @@ -268,10 +268,10 @@ Function Get-Policies { $folder = $service.GetFolder('\') $task = $folder.GetTask("Winget-AutoUpdate") $definition = $task.Definition - for($triggerId=1; $triggerId -le $definition.Triggers.Count; $triggerId++){ - if($definition.Triggers.Item($triggerId).Type -eq "9"){ + for ($triggerId = 1; $triggerId -le $definition.Triggers.Count; $triggerId++) { + if ($definition.Triggers.Item($triggerId).Type -eq "9") { $definition.Triggers.Remove($triggerId) - $triggerId-=1 + $triggerId -= 1 } } $folder.RegisterTaskDefinition($task.Name, $definition, 4, $null, $null, $null) | Out-Null diff --git a/Winget-AutoUpdate/functions/Get-WAUAvailableVersion.ps1 b/Winget-AutoUpdate/functions/Get-WAUAvailableVersion.ps1 index 80c5fd8..20fd1e9 100644 --- a/Winget-AutoUpdate/functions/Get-WAUAvailableVersion.ps1 +++ b/Winget-AutoUpdate/functions/Get-WAUAvailableVersion.ps1 @@ -1,4 +1,4 @@ -#Function to get latest WAU available version on Github +#Function to get the latest WAU available version on Github function Get-WAUAvailableVersion { diff --git a/Winget-AutoUpdate/functions/Get-WingetCmd.ps1 b/Winget-AutoUpdate/functions/Get-WingetCmd.ps1 index 0dddf0a..7399b1f 100644 --- a/Winget-AutoUpdate/functions/Get-WingetCmd.ps1 +++ b/Winget-AutoUpdate/functions/Get-WingetCmd.ps1 @@ -1,4 +1,4 @@ -#Function to get Winget Command regarding execution context (User, System...) +#Function to get the winget command regarding execution context (User, System...) Function Get-WingetCmd { diff --git a/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 b/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 index d0e861b..27c10e8 100644 --- a/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 +++ b/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 @@ -1,4 +1,4 @@ -#Function to get outdated app list, in formatted array +#Function to get the outdated app list, in formatted array function Get-WingetOutdatedApps { class Software { @@ -51,8 +51,8 @@ function Get-WingetOutdatedApps { $idStart = $lines[$fl].IndexOf($index[1]) $versionStart = $lines[$fl].IndexOf($index[2]) $availableStart = $lines[$fl].IndexOf($index[3]) - } - #(Alphanumeric | Literal . | Alphanumeric) - the only unique thing in common for lines with applications + } + #(Alphanumeric | Literal . | Alphanumeric) - the only unique thing in common for lines with applications if ($line -match "\w\.\w") { $software = [Software]::new() $software.Name = $line.Substring(0, $idStart).TrimEnd() diff --git a/Winget-AutoUpdate/functions/Get-WingetSystemApps.ps1 b/Winget-AutoUpdate/functions/Get-WingetSystemApps.ps1 index b682f62..8f653ea 100644 --- a/Winget-AutoUpdate/functions/Get-WingetSystemApps.ps1 +++ b/Winget-AutoUpdate/functions/Get-WingetSystemApps.ps1 @@ -1,6 +1,6 @@ function Get-WingetSystemApps { - #Json File where to export system installed apps + #Json File, where to export system installed apps $jsonFile = "$WorkingDir\winget_system_apps.txt" #Get list of installed Winget apps to json file diff --git a/Winget-AutoUpdate/functions/Invoke-LogRotation.ps1 b/Winget-AutoUpdate/functions/Invoke-LogRotation.ps1 index 889de60..8699421 100644 --- a/Winget-AutoUpdate/functions/Invoke-LogRotation.ps1 +++ b/Winget-AutoUpdate/functions/Invoke-LogRotation.ps1 @@ -1,4 +1,4 @@ -#Function rotate the logs +#Function to rotate the logs function Invoke-LogRotation ($LogFile, $MaxLogFiles, $MaxLogSize) { <# diff --git a/Winget-AutoUpdate/functions/Invoke-ModsProtect.ps1 b/Winget-AutoUpdate/functions/Invoke-ModsProtect.ps1 index b800571..1b56707 100644 --- a/Winget-AutoUpdate/functions/Invoke-ModsProtect.ps1 +++ b/Winget-AutoUpdate/functions/Invoke-ModsProtect.ps1 @@ -1,4 +1,4 @@ -#Function to check if Mods Directory is secured. +#Function to check if the mods directory is secured. #Security: Mods directory must be protected (Users could create scripts of their own - then they'll run in System Context)! #Check if Local Users have write rights in Mods directory or not (and take action if necessary): @@ -12,16 +12,16 @@ function Invoke-ModsProtect ($ModsPath) { $ntAccount = $userSID.Translate([System.Security.Principal.NTAccount]) $userName = $ntAccount.Value $userRights = [System.Security.AccessControl.FileSystemRights]"Write" - + $hasWriteAccess = $False - + foreach ($access in $acl.Access) { if ($access.IdentityReference.Value -eq $userName -and $access.FileSystemRights -eq $userRights) { $hasWriteAccess = $True break } } - + if ($hasWriteAccess) { #Disable inheritance $acl.SetAccessRuleProtection($True, $True) @@ -29,32 +29,32 @@ function Invoke-ModsProtect ($ModsPath) { $acl.Access | ForEach-Object { $acl.RemoveAccessRule($_) } #SYSTEM Full - S-1-5-18 $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-18") - $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID,"FullControl","ContainerInherit,ObjectInherit","None","Allow") + $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "FullControl", "ContainerInherit,ObjectInherit", "None", "Allow") $acl.SetAccessRule($rule) # Save the updated ACL Set-Acl -Path $directory.FullName -AclObject $acl - + #Administrators Full - S-1-5-32-544 $acl = Get-Acl -Path $directory.FullName $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-32-544") - $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID,"FullControl","ContainerInherit,ObjectInherit","None","Allow") + $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "FullControl", "ContainerInherit,ObjectInherit", "None", "Allow") $acl.SetAccessRule($rule) Set-Acl -Path $directory.FullName -AclObject $acl - + #Local Users ReadAndExecute - S-1-5-32-545 S-1-5-11 $acl = Get-Acl -Path $directory.FullName $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-32-545") - $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "ReadAndExecute","ContainerInherit,ObjectInherit","None","Allow") + $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "ReadAndExecute", "ContainerInherit,ObjectInherit", "None", "Allow") $acl.SetAccessRule($rule) Set-Acl -Path $directory.FullName -AclObject $acl - + #Authenticated Users ReadAndExecute - S-1-5-11 $acl = Get-Acl -Path $directory.FullName $userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-11") - $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "ReadAndExecute","ContainerInherit,ObjectInherit","None","Allow") + $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "ReadAndExecute", "ContainerInherit,ObjectInherit", "None", "Allow") $acl.SetAccessRule($rule) Set-Acl -Path $directory.FullName -AclObject $acl - + return $True } return $False diff --git a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 index 6b54125..1f8b643 100644 --- a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 +++ b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 @@ -1,4 +1,4 @@ -#Function to make actions post WAU update +#Function to make actions after WAU update function Invoke-PostUpdateActions { @@ -12,7 +12,7 @@ function Invoke-PostUpdateActions { } Write-Log "-> Checking prerequisites..." "yellow" - + #Check if Visual C++ 2019 or 2022 installed $Visual2019 = "Microsoft Visual C++ 2015-2019 Redistributable*" $Visual2022 = "Microsoft Visual C++ 2015-2022 Redistributable*" diff --git a/Winget-AutoUpdate/functions/Start-Init.ps1 b/Winget-AutoUpdate/functions/Start-Init.ps1 index 14c90bf..e0b6a83 100644 --- a/Winget-AutoUpdate/functions/Start-Init.ps1 +++ b/Winget-AutoUpdate/functions/Start-Init.ps1 @@ -1,4 +1,4 @@ -#Initialisation +# Initialisation function Start-Init { diff --git a/Winget-AutoUpdate/functions/Start-NotifTask.ps1 b/Winget-AutoUpdate/functions/Start-NotifTask.ps1 index 668f387..e78062d 100644 --- a/Winget-AutoUpdate/functions/Start-NotifTask.ps1 +++ b/Winget-AutoUpdate/functions/Start-NotifTask.ps1 @@ -1,4 +1,4 @@ -#Function to send notifications to user +#Function to send the notifications to user function Start-NotifTask { @@ -31,7 +31,7 @@ function Start-NotifTask { $XMLbinding.Attributes.Append($XMLbindingAtt1) | Out-Null $XMLimagepath = "$WorkingDir\icons\$MessageType.png" - if (Test-Path $XMLimagepath){ + if (Test-Path $XMLimagepath) { # Creation of a image node $XMLimage = $ToastTemplate.CreateElement("image") $XMLbinding.AppendChild($XMLimage) | Out-Null @@ -43,7 +43,7 @@ function Start-NotifTask { $XMLimage.Attributes.Append($XMLimageAtt2) | Out-Null } - if ($Title){ + if ($Title) { # Creation of a text node $XMLtitle = $ToastTemplate.CreateElement("text") $XMLtitleText = $ToastTemplate.CreateTextNode($Title) @@ -51,7 +51,7 @@ function Start-NotifTask { $XMLbinding.AppendChild($XMLtitle) | Out-Null } - if ($Message){ + if ($Message) { # Creation of a text node $XMLtext = $ToastTemplate.CreateElement("text") $XMLtextText = $ToastTemplate.CreateTextNode($Message) @@ -59,7 +59,7 @@ function Start-NotifTask { $XMLbinding.AppendChild($XMLtext) | Out-Null } - if ($Body){ + if ($Body) { # Creation of a group node $XMLgroup = $ToastTemplate.CreateElement("group") $XMLbinding.AppendChild($XMLgroup) | Out-Null @@ -91,7 +91,7 @@ function Start-NotifTask { $XMLactionAtt1 = $ToastTemplate.CreateAttribute("content") $XMLactionAtt1.Value = $Button1Text $XMLaction.Attributes.Append($XMLactionAtt1) | Out-Null - if ($Button1Action){ + if ($Button1Action) { $XMLactionAtt2 = $ToastTemplate.CreateAttribute("arguments") $XMLactionAtt2.Value = $Button1Action $XMLaction.Attributes.Append($XMLactionAtt2) | Out-Null @@ -126,7 +126,7 @@ function Start-NotifTask { $ToastTemplate.LastChild.AppendChild($XMLactions) | Out-Null $ToastTemplate.LastChild.AppendChild($XMLtag) | Out-Null - if ($OnClickAction){ + if ($OnClickAction) { $ToastTemplate.toast.SetAttribute("activationType", "Protocol") | Out-Null $ToastTemplate.toast.SetAttribute("launch", $OnClickAction) | Out-Null } diff --git a/Winget-AutoUpdate/functions/Test-ListPath.ps1 b/Winget-AutoUpdate/functions/Test-ListPath.ps1 index f9a8fe6..2ec3d7b 100644 --- a/Winget-AutoUpdate/functions/Test-ListPath.ps1 +++ b/Winget-AutoUpdate/functions/Test-ListPath.ps1 @@ -1,4 +1,4 @@ -#Function to check Black/White List External Path +#Function to check Block/Allow List External Path function Test-ListPath ($ListPath, $UseWhiteList, $WingetUpdatePath) { # URL, UNC or Local Path diff --git a/Winget-AutoUpdate/functions/Test-Mods.ps1 b/Winget-AutoUpdate/functions/Test-Mods.ps1 index 560df80..f46d4da 100644 --- a/Winget-AutoUpdate/functions/Test-Mods.ps1 +++ b/Winget-AutoUpdate/functions/Test-Mods.ps1 @@ -1,4 +1,4 @@ -#Function to check if modification exists in 'mods' directory +#Function to check if modification exists within 'mods' directory function Test-Mods ($app) { diff --git a/Winget-AutoUpdate/functions/Test-ModsPath.ps1 b/Winget-AutoUpdate/functions/Test-ModsPath.ps1 index e9deb5e..65841f5 100644 --- a/Winget-AutoUpdate/functions/Test-ModsPath.ps1 +++ b/Winget-AutoUpdate/functions/Test-ModsPath.ps1 @@ -1,4 +1,4 @@ -#Function to check Mods External Path +#Function to check mods External Path function Test-ModsPath ($ModsPath, $WingetUpdatePath, $AzureBlobSASURL) { # URL, UNC or Local Path @@ -30,7 +30,7 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath, $AzureBlobSASURL) { # Collect the external list of href links $BinLinks = $BinResponse.Links | Select-Object -ExpandProperty HREF #If there's a directory path in the HREF:s, delete it (IIS) - $CleanBinLinks = $BinLinks -replace "/.*/","" + $CleanBinLinks = $BinLinks -replace "/.*/", "" #Modify strings to HREF:s $index = 0 foreach ($Bin in $CleanBinLinks) { @@ -41,14 +41,14 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath, $AzureBlobSASURL) { } #Delete Local Bins that don't exist Externally $index = 0 - $CleanLinks = $BinLinks -replace "/.*/","" + $CleanLinks = $BinLinks -replace "/.*/", "" foreach ($Bin in $InternalBinsNames) { If ($CleanLinks -notcontains "$Bin") { Remove-Item $LocalMods\bins\$Bin -Force -ErrorAction SilentlyContinue | Out-Null } $index++ } - $CleanBinLinks = $BinLinks -replace "/.*/","" + $CleanBinLinks = $BinLinks -replace "/.*/", "" $Bin = "" #Loop through all links $wc = New-Object System.Net.WebClient @@ -56,7 +56,7 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath, $AzureBlobSASURL) { #Check for .exe in listing/HREF:s in an index page pointing to .exe if ($_ -like "*.exe") { $dateExternalBin = "" - $dateLocalBin ="" + $dateLocalBin = "" $wc.OpenRead("$ExternalBins/$_").Close() | Out-Null $dateExternalBin = ([DateTime]$wc.ResponseHeaders['Last-Modified']).ToString("yyyy-MM-dd HH:mm:ss") if (Test-Path -Path $LocalMods"\bins\"$_) { @@ -64,7 +64,7 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath, $AzureBlobSASURL) { } if ($dateExternalBin -gt $dateLocalBin) { $SaveBin = Join-Path -Path "$LocalMods\bins" -ChildPath $_ - Invoke-WebRequest -Uri "$ExternalBins/$_" -OutFile $SaveBin.Replace("%20"," ") -UseBasicParsing + Invoke-WebRequest -Uri "$ExternalBins/$_" -OutFile $SaveBin.Replace("%20", " ") -UseBasicParsing } } } @@ -74,8 +74,8 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath, $AzureBlobSASURL) { $ModLinks = $WebResponse.Links | Select-Object -ExpandProperty HREF #If there's a directory path in the HREF:s, delete it (IIS) - $CleanLinks = $ModLinks -replace "/.*/","" - + $CleanLinks = $ModLinks -replace "/.*/", "" + #Modify strings to HREF:s $index = 0 foreach ($Mod in $CleanLinks) { @@ -88,7 +88,7 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath, $AzureBlobSASURL) { #Delete Local Mods that don't exist Externally $DeletedMods = 0 $index = 0 - $CleanLinks = $ModLinks -replace "/.*/","" + $CleanLinks = $ModLinks -replace "/.*/", "" foreach ($Mod in $InternalModsNames) { If ($CleanLinks -notcontains "$Mod") { Remove-Item $LocalMods\$Mod -Force -ErrorAction SilentlyContinue | Out-Null @@ -96,8 +96,8 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath, $AzureBlobSASURL) { } $index++ } - - $CleanLinks = $ModLinks -replace "/.*/","" + + $CleanLinks = $ModLinks -replace "/.*/", "" #Loop through all links $wc = New-Object System.Net.WebClient @@ -106,13 +106,13 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath, $AzureBlobSASURL) { if (($_ -like "*.ps1") -or ($_ -like "*.txt")) { try { $dateExternalMod = "" - $dateLocalMod ="" + $dateLocalMod = "" $wc.OpenRead("$ExternalMods/$_").Close() | Out-Null $dateExternalMod = ([DateTime]$wc.ResponseHeaders['Last-Modified']).ToString("yyyy-MM-dd HH:mm:ss") if (Test-Path -Path $LocalMods"\"$_) { $dateLocalMod = (Get-Item "$LocalMods\$_").LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss") } - + if ($dateExternalMod -gt $dateLocalMod) { try { $SaveMod = Join-Path -Path "$LocalMods\" -ChildPath $_ @@ -145,8 +145,8 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath, $AzureBlobSASURL) { $AZCopySyncOutput = & $WingetUpdatePath\azcopy.exe sync "$AzureBlobSASURL" "$LocalMods" --from-to BlobLocal --delete-destination=true $AZCopyOutputLines = $AZCopySyncOutput.Split([Environment]::NewLine) - - foreach( $_ in $AZCopyOutputLines){ + + foreach ( $_ in $AZCopyOutputLines) { $AZCopySyncAdditionsRegex = [regex]::new("(?<=Number of Copy Transfers Completed:\s+)\d+") $AZCopySyncDeletionsRegex = [regex]::new("(?<=Number of Deletions at Destination:\s+)\d+") $AZCopySyncErrorRegex = [regex]::new("^Cannot perform sync due to error:") @@ -154,15 +154,15 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath, $AzureBlobSASURL) { $AZCopyAdditions = [int] $AZCopySyncAdditionsRegex.Match($_).Value $AZCopyDeletions = [int] $AZCopySyncDeletionsRegex.Match($_).Value - if ($AZCopyAdditions -ne 0){ + if ($AZCopyAdditions -ne 0) { $ModsUpdated = $AZCopyAdditions } - if ($AZCopyDeletions -ne 0){ + if ($AZCopyDeletions -ne 0) { $DeletedMods = $AZCopyDeletions } - if ($AZCopySyncErrorRegex.Match($_).Value){ + if ($AZCopySyncErrorRegex.Match($_).Value) { Write-Log "AZCopy Sync Error! $_" } } @@ -179,15 +179,15 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath, $AzureBlobSASURL) { if (Test-Path -Path $ExternalBins"\*.exe") { $ExternalBinsNames = Get-ChildItem -Path $ExternalBins -Name -Recurse -Include *.exe #Delete Local Bins that don't exist Externally - foreach ($Bin in $InternalBinsNames){ - If ($Bin -notin $ExternalBinsNames ){ + foreach ($Bin in $InternalBinsNames) { + If ($Bin -notin $ExternalBinsNames ) { Remove-Item $LocalMods\bins\$Bin -Force -ErrorAction SilentlyContinue | Out-Null } } #Copy newer external bins - foreach ($Bin in $ExternalBinsNames){ + foreach ($Bin in $ExternalBinsNames) { $dateExternalBin = "" - $dateLocalBin ="" + $dateLocalBin = "" if (Test-Path -Path $LocalMods"\bins\"$Bin) { $dateLocalBin = (Get-Item "$LocalMods\bins\$Bin").LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss") } @@ -201,20 +201,20 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath, $AzureBlobSASURL) { if ((Test-Path -Path $ExternalMods"\*.ps1") -or (Test-Path -Path $ExternalMods"\*.txt")) { #Get File Names Externally $ExternalModsNames = Get-ChildItem -Path $ExternalMods -Name -Recurse -Include *.ps1, *.txt - + #Delete Local Mods that don't exist Externally $DeletedMods = 0 - foreach ($Mod in $InternalModsNames){ - If ($Mod -notin $ExternalModsNames ){ + foreach ($Mod in $InternalModsNames) { + If ($Mod -notin $ExternalModsNames ) { Remove-Item $LocalMods\$Mod -Force -ErrorAction SilentlyContinue | Out-Null $DeletedMods++ } } #Copy newer external mods - foreach ($Mod in $ExternalModsNames){ + foreach ($Mod in $ExternalModsNames) { $dateExternalMod = "" - $dateLocalMod ="" + $dateLocalMod = "" if (Test-Path -Path $LocalMods"\"$Mod) { $dateLocalMod = (Get-Item "$LocalMods\$Mod").LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss") } diff --git a/Winget-AutoUpdate/functions/Test-Network.ps1 b/Winget-AutoUpdate/functions/Test-Network.ps1 index a726373..7478ae7 100644 --- a/Winget-AutoUpdate/functions/Test-Network.ps1 +++ b/Winget-AutoUpdate/functions/Test-Network.ps1 @@ -1,4 +1,4 @@ -#Function to check connectivity +#Function to check the connectivity function Test-Network { diff --git a/Winget-AutoUpdate/functions/Test-PendingReboot.ps1 b/Winget-AutoUpdate/functions/Test-PendingReboot.ps1 index 55bc72f..bb1d52e 100644 --- a/Winget-AutoUpdate/functions/Test-PendingReboot.ps1 +++ b/Winget-AutoUpdate/functions/Test-PendingReboot.ps1 @@ -1,4 +1,4 @@ -#Function to check if there's a Pending Reboot +#Function to check if there is a Pending Reboot function Test-PendingReboot { diff --git a/Winget-AutoUpdate/functions/Update-App.ps1 b/Winget-AutoUpdate/functions/Update-App.ps1 index 11096a4..5928308 100644 --- a/Winget-AutoUpdate/functions/Update-App.ps1 +++ b/Winget-AutoUpdate/functions/Update-App.ps1 @@ -1,10 +1,10 @@ -#Function to Update an App +#Function to update an App Function Update-App ($app) { #Get App Info $ReleaseNoteURL = Get-AppInfo $app.Id - if ($ReleaseNoteURL){ + if ($ReleaseNoteURL) { $Button1Text = $NotifLocale.local.outputs.output[10].message } @@ -30,11 +30,11 @@ Function Update-App ($app) { #Run Winget Upgrade command if ($ModsOverride) { - Write-Log "-> Running (overriding default): Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements --override $ModsOverride" + Write-Log "-> Running (overriding default): Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements --override $ModsOverride" & $Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements --override $ModsOverride | Tee-Object -file $LogFile -Append } else { - Write-Log "-> Running: Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements -h" + Write-Log "-> Running: Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements -h" & $Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append } @@ -60,13 +60,13 @@ Function Update-App ($app) { #If app failed to upgrade, run Install command Write-Log "-> An upgrade for $($app.Name) failed, now trying an install instead..." "Yellow" - + if ($ModsOverride) { - Write-Log "-> Running (overriding default): Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements --override $ModsOverride" + Write-Log "-> Running (overriding default): Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements --override $ModsOverride" & $Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements --override $ModsOverride | Tee-Object -file $LogFile -Append } else { - Write-Log "-> Running: Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements -h" + Write-Log "-> Running: Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements -h" & $Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append } diff --git a/Winget-AutoUpdate/functions/Update-WAU.ps1 b/Winget-AutoUpdate/functions/Update-WAU.ps1 index 25a158f..6fe3aa2 100644 --- a/Winget-AutoUpdate/functions/Update-WAU.ps1 +++ b/Winget-AutoUpdate/functions/Update-WAU.ps1 @@ -1,4 +1,4 @@ -#Function to Update WAU +#Function to update WAU function Update-WAU { diff --git a/Winget-AutoUpdate/functions/Write-Log.ps1 b/Winget-AutoUpdate/functions/Write-Log.ps1 index aa30cb2..e30f6f1 100644 --- a/Winget-AutoUpdate/functions/Write-Log.ps1 +++ b/Winget-AutoUpdate/functions/Write-Log.ps1 @@ -1,4 +1,4 @@ -#Write Log Function +#Write to Log Function function Write-Log ($LogMsg, $LogColor = "White") { diff --git a/Winget-AutoUpdate/mods/_AppID-template.ps1 b/Winget-AutoUpdate/mods/_AppID-template.ps1 index 7a9aae3..72eb8df 100644 --- a/Winget-AutoUpdate/mods/_AppID-template.ps1 +++ b/Winget-AutoUpdate/mods/_AppID-template.ps1 @@ -1,6 +1,6 @@ <# ARRAYS/VARIABLES #> #App to Run (as SYSTEM) -#$RunWait = $False if it shouldn't be waited for completion. Example: +#$RunWait = $False if it shouldn't be waited for completion. For example: #$RunSystem = "$PSScriptRoot\bins\MsiZap.exe" #$RunSwitch = "tw! {GUID}" $RunSystem = "" diff --git a/Winget-AutoUpdate/mods/_Mods-Functions.ps1 b/Winget-AutoUpdate/mods/_Mods-Functions.ps1 index 2f6ee3e..63e64d1 100644 --- a/Winget-AutoUpdate/mods/_Mods-Functions.ps1 +++ b/Winget-AutoUpdate/mods/_Mods-Functions.ps1 @@ -1,61 +1,56 @@ -#Common shared functions for mods handling +#Common shared functions to handle the mods function Invoke-ModsApp ($Run, $RunSwitch, $RunWait, $User) { if (Test-Path "$Run") { - if (!$RunSwitch) {$RunSwitch = " "} - if (!$User) { - if (!$RunWait) { - Start-Process $Run -ArgumentList $RunSwitch - } - else { - Start-Process $Run -ArgumentList $RunSwitch -Wait - } - } - else { - Start-Process explorer $Run - } + if (!$RunSwitch) { $RunSwitch = " " } + if (!$User) { + if (!$RunWait) { + Start-Process $Run -ArgumentList $RunSwitch + } + else { + Start-Process $Run -ArgumentList $RunSwitch -Wait + } + } + else { + Start-Process explorer $Run + } } Return } function Stop-ModsProc ($Proc) { - foreach ($process in $Proc) - { + foreach ($process in $Proc) { Stop-Process -Name $process -Force -ErrorAction SilentlyContinue | Out-Null } Return } function Wait-ModsProc ($Wait) { - foreach ($process in $Wait) - { + foreach ($process in $Wait) { Get-Process $process -ErrorAction SilentlyContinue | Foreach-Object { $_.WaitForExit() } } Return } function Install-WingetID ($WingetIDInst) { - foreach ($app in $WingetIDInst) - { + foreach ($app in $WingetIDInst) { & $Winget install --id $app --accept-package-agreements --accept-source-agreements -h } Return } function Uninstall-WingetID ($WingetIDUninst) { - foreach ($app in $WingetIDUninst) - { + foreach ($app in $WingetIDUninst) { & $Winget uninstall --id $app -e --accept-source-agreements -h } Return } function Uninstall-ModsApp ($AppUninst) { - foreach ($app in $AppUninst) - { + foreach ($app in $AppUninst) { $InstalledSoftware = Get-ChildItem "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall" - foreach ($obj in $InstalledSoftware){ + foreach ($obj in $InstalledSoftware) { if ($obj.GetValue('DisplayName') -like $App) { $UninstallString = $obj.GetValue('UninstallString') $CleanedUninstallString = $UninstallString.Trim([char]0x0022) @@ -111,7 +106,7 @@ function Uninstall-ModsApp ($AppUninst) { } if (!$x64) { $InstalledSoftware = Get-ChildItem "HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall" - foreach ($obj in $InstalledSoftware){ + foreach ($obj in $InstalledSoftware) { if ($obj.GetValue('DisplayName') -like $App) { $UninstallString = $obj.GetValue('UninstallString') $CleanedUninstallString = $UninstallString.Trim([char]0x0022) @@ -169,8 +164,7 @@ function Uninstall-ModsApp ($AppUninst) { Return } function Remove-ModsLnk ($Lnk) { - foreach ($link in $Lnk) - { + foreach ($link in $Lnk) { Remove-Item -Path "${env:Public}\Desktop\$link.lnk" -Force -ErrorAction SilentlyContinue | Out-Null } Return @@ -178,7 +172,7 @@ function Remove-ModsLnk ($Lnk) { function Add-ModsReg ($AddKey, $AddValue, $AddTypeData, $AddType) { if ($AddKey -like "HKEY_LOCAL_MACHINE*") { - $AddKey = $AddKey.replace("HKEY_LOCAL_MACHINE","HKLM:") + $AddKey = $AddKey.replace("HKEY_LOCAL_MACHINE", "HKLM:") } if (!(Test-Path "$AddKey")) { New-Item $AddKey -Force -ErrorAction SilentlyContinue | Out-Null @@ -189,7 +183,7 @@ function Add-ModsReg ($AddKey, $AddValue, $AddTypeData, $AddType) { function Remove-ModsReg ($DelKey, $DelValue) { if ($DelKey -like "HKEY_LOCAL_MACHINE*") { - $DelKey = $DelKey.replace("HKEY_LOCAL_MACHINE","HKLM:") + $DelKey = $DelKey.replace("HKEY_LOCAL_MACHINE", "HKLM:") } if (Test-Path "$DelKey") { if (!$DelValue) { @@ -203,8 +197,7 @@ function Remove-ModsReg ($DelKey, $DelValue) { } function Remove-ModsFile ($DelFile) { - foreach ($file in $DelFile) - { + foreach ($file in $DelFile) { if (Test-Path "$file") { Remove-Item -Path $file -Force -Recurse -ErrorAction SilentlyContinue | Out-Null } @@ -228,14 +221,13 @@ function Copy-ModsFile ($CopyFile, $CopyTo) { function Edit-ModsFile ($File, $FindText, $ReplaceText) { if (Test-Path "$File") { - ((Get-Content -path $File -Raw) -replace "$FindText","$ReplaceText") | Set-Content -Path $File -Force -ErrorAction SilentlyContinue | Out-Null + ((Get-Content -path $File -Raw) -replace "$FindText", "$ReplaceText") | Set-Content -Path $File -Force -ErrorAction SilentlyContinue | Out-Null } Return } function Grant-ModsPath ($GrantPath) { - foreach ($path in $GrantPath) - { + foreach ($path in $GrantPath) { if (Test-Path "$path") { $NewAcl = Get-Acl -Path $path $identity = New-Object System.Security.Principal.SecurityIdentifier S-1-5-11 From 1f4bb8bcd6d792c7f38dbd689a0052065178f013 Mon Sep 17 00:00:00 2001 From: Fabian Seitz Date: Sat, 1 Apr 2023 16:08:52 +0200 Subject: [PATCH 055/131] Update megalinter and rename Write-Log function to Write-ToLog --- .github/.powershell-psscriptanalyzer.psd1 | 5 +- .github/workflows/mega-linter.yml | 2 +- Winget-AutoUpdate/Winget-Upgrade.ps1 | 92 +++++++++---------- Winget-AutoUpdate/functions/Get-AZCopy.ps1 | 14 +-- .../functions/Get-WAUAvailableVersion.ps1 | 2 +- Winget-AutoUpdate/functions/Get-WingetCmd.ps1 | 4 +- .../functions/Invoke-LogRotation.ps1 | 12 +-- .../functions/Invoke-PostUpdateActions.ps1 | 56 +++++------ Winget-AutoUpdate/functions/Test-ModsPath.ps1 | 10 +- Winget-AutoUpdate/functions/Test-Network.ps1 | 14 +-- Winget-AutoUpdate/functions/Update-App.ps1 | 30 +++--- Winget-AutoUpdate/functions/Update-WAU.ps1 | 14 +-- .../{Write-Log.ps1 => Write-ToLog.ps1} | 2 +- 13 files changed, 130 insertions(+), 127 deletions(-) rename Winget-AutoUpdate/functions/{Write-Log.ps1 => Write-ToLog.ps1} (80%) diff --git a/.github/.powershell-psscriptanalyzer.psd1 b/.github/.powershell-psscriptanalyzer.psd1 index 6128b5c..21f77be 100644 --- a/.github/.powershell-psscriptanalyzer.psd1 +++ b/.github/.powershell-psscriptanalyzer.psd1 @@ -11,6 +11,9 @@ 'PSPossibleIncorrectComparisonWithNull', 'PSAvoidTrailingWhitespace', 'PSUseApprovedVerbs', - 'PSAvoidUsingWMICmdlet' + 'PSAvoidUsingWMICmdlet', + 'PSReviewUnusedParameter', + 'PSUseDeclaredVarsMoreThanAssignment', + 'PSUseShouldProcessForStateChangingFunctions' ) } \ No newline at end of file diff --git a/.github/workflows/mega-linter.yml b/.github/workflows/mega-linter.yml index a26541b..ff9d2c4 100644 --- a/.github/workflows/mega-linter.yml +++ b/.github/workflows/mega-linter.yml @@ -45,7 +45,7 @@ jobs: env: # All available variables are described in documentation # https://megalinter.github.io/configuration/ - VALIDATE_ALL_CODEBASE: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} # Validates all source when push on main, else just the git diff with main. Override with true if you always want to lint all sources + VALIDATE_ALL_CODEBASE: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} # Validates all source when push on main, else just the git diff with main. Override with true if you always want to lint all sources GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SPELL_CSPELL_CONFIG_FILE: .github/cspell.json POWERSHELL_POWERSHELL_CONFIG_FILE: .github/.powershell-psscriptanalyzer.psd1 diff --git a/Winget-AutoUpdate/Winget-Upgrade.ps1 b/Winget-AutoUpdate/Winget-Upgrade.ps1 index 9bede9d..d8b015b 100644 --- a/Winget-AutoUpdate/Winget-Upgrade.ps1 +++ b/Winget-AutoUpdate/Winget-Upgrade.ps1 @@ -19,17 +19,17 @@ $Script:WAUConfig = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Cur #Log running context and more... if ($IsSystem) { - Write-Log "Running in System context" + Write-ToLog "Running in System context" #Get and set Domain/Local Policies (GPO) $ActivateGPOManagement, $ChangedSettings = Get-Policies if ($ActivateGPOManagement) { - Write-Log "Activated WAU GPO Management detected, comparing..." + Write-ToLog "Activated WAU GPO Management detected, comparing..." if ($null -ne $ChangedSettings -and $ChangedSettings -ne 0) { - Write-Log "Changed settings detected and applied" "Yellow" + Write-ToLog "Changed settings detected and applied" "Yellow" } else { - Write-Log "No Changed settings detected" "Yellow" + Write-ToLog "No Changed settings detected" "Yellow" } } @@ -54,7 +54,7 @@ if ($IsSystem) { #LogRotation if System $LogRotate = Invoke-LogRotation $LogFile $MaxLogFiles $MaxLogSize if ($LogRotate -eq $False) { - Write-Log "An Exception occured during Log Rotation..." + Write-ToLog "An Exception occured during Log Rotation..." } #Run post update actions if necessary if run as System @@ -66,12 +66,12 @@ if ($IsSystem) { Add-ScopeMachine $SettingsPath } else { - Write-Log "Running in User context" + Write-ToLog "Running in User context" } #Get Notif Locale function $LocaleDisplayName = Get-NotifLocale -Write-Log "Notification Level: $($WAUConfig.WAU_NotificationLevel). Notification Language: $LocaleDisplayName" "Cyan" +Write-ToLog "Notification Level: $($WAUConfig.WAU_NotificationLevel). Notification Language: $LocaleDisplayName" "Cyan" #Check network connectivity if (Test-Network) { @@ -81,26 +81,26 @@ if (Test-Network) { if ($TestWinget) { #Get Current Version $WAUCurrentVersion = $WAUConfig.DisplayVersion - Write-Log "WAU current version: $WAUCurrentVersion" + Write-ToLog "WAU current version: $WAUCurrentVersion" if ($IsSystem) { #Check if WAU update feature is enabled or not if run as System $WAUDisableAutoUpdate = $WAUConfig.WAU_DisableAutoUpdate #If yes then check WAU update if run as System if ($WAUDisableAutoUpdate -eq 1) { - Write-Log "WAU AutoUpdate is Disabled." "Gray" + Write-ToLog "WAU AutoUpdate is Disabled." "Gray" } else { - Write-Log "WAU AutoUpdate is Enabled." "Green" + Write-ToLog "WAU AutoUpdate is Enabled." "Green" #Get Available Version $WAUAvailableVersion = Get-WAUAvailableVersion #Compare if ([version]$WAUAvailableVersion -gt [version]$WAUCurrentVersion) { #If new version is available, update it - Write-Log "WAU Available version: $WAUAvailableVersion" "Yellow" + Write-ToLog "WAU Available version: $WAUAvailableVersion" "Yellow" Update-WAU } else { - Write-Log "WAU is up to date." "Green" + Write-ToLog "WAU is up to date." "Green" } } @@ -112,35 +112,35 @@ if (Test-Network) { #Get External ListPath if run as System if ($WAUConfig.WAU_ListPath) { $ListPathClean = $($WAUConfig.WAU_ListPath.TrimEnd(" ", "\", "/")) - Write-Log "WAU uses External Lists from: $ListPathClean" + Write-ToLog "WAU uses External Lists from: $ListPathClean" if ($ListPathClean -ne "GPO") { $NewList = Test-ListPath $ListPathClean $WAUConfig.WAU_UseWhiteList $WAUConfig.InstallLocation.TrimEnd(" ", "\") if ($ReachNoPath) { - Write-Log "Couldn't reach/find/compare/copy from $ListPathClean..." "Red" + Write-ToLog "Couldn't reach/find/compare/copy from $ListPathClean..." "Red" if ($ListPathClean -notlike "http*") { if (Test-Path -Path "$ListPathClean" -PathType Leaf) { - Write-Log "PATH must end with a Directory, not a File..." "Red" + Write-ToLog "PATH must end with a Directory, not a File..." "Red" } } else { if ($ListPathClean -match "_apps.txt") { - Write-Log "PATH must end with a Directory, not a File..." "Red" + Write-ToLog "PATH must end with a Directory, not a File..." "Red" } } $Script:ReachNoPath = $False } if ($NewList) { - Write-Log "Newer List downloaded/copied to local path: $($WAUConfig.InstallLocation.TrimEnd(" ", "\"))" "Yellow" + Write-ToLog "Newer List downloaded/copied to local path: $($WAUConfig.InstallLocation.TrimEnd(" ", "\"))" "Yellow" } else { if ($WAUConfig.WAU_UseWhiteList -and (Test-Path "$WorkingDir\included_apps.txt")) { - Write-Log "List (white) is up to date." "Green" + Write-ToLog "List (white) is up to date." "Green" } elseif (!$WAUConfig.WAU_UseWhiteList -and (Test-Path "$WorkingDir\excluded_apps.txt")) { - Write-Log "List (black) is up to date." "Green" + Write-ToLog "List (black) is up to date." "Green" } else { - Write-Log "Critical: White/Black List doesn't exist, exiting..." "Red" + Write-ToLog "Critical: White/Black List doesn't exist, exiting..." "Red" New-Item "$WorkingDir\logs\error.txt" -Value "White/Black List doesn't exist" -Force Exit 1 } @@ -151,25 +151,25 @@ if (Test-Network) { #Get External ModsPath if run as System if ($WAUConfig.WAU_ModsPath) { $ModsPathClean = $($WAUConfig.WAU_ModsPath.TrimEnd(" ", "\", "/")) - Write-Log "WAU uses External Mods from: $ModsPathClean" + Write-ToLog "WAU uses External Mods from: $ModsPathClean" $NewMods, $DeletedMods = Test-ModsPath $ModsPathClean $WAUConfig.InstallLocation.TrimEnd(" ", "\") $WAUConfig.WAU_AzureBlobSASURL.TrimEnd(" ") if ($ReachNoPath) { - Write-Log "Couldn't reach/find/compare/copy from $ModsPathClean..." "Red" + Write-ToLog "Couldn't reach/find/compare/copy from $ModsPathClean..." "Red" $Script:ReachNoPath = $False } if ($NewMods -gt 0) { - Write-Log "$NewMods newer Mods downloaded/copied to local path: $($WAUConfig.InstallLocation.TrimEnd(" ", "\"))\mods" "Yellow" + Write-ToLog "$NewMods newer Mods downloaded/copied to local path: $($WAUConfig.InstallLocation.TrimEnd(" ", "\"))\mods" "Yellow" } else { if (Test-Path "$WorkingDir\mods\*.ps1") { - Write-Log "Mods are up to date." "Green" + Write-ToLog "Mods are up to date." "Green" } else { - Write-Log "No Mods are implemented..." "Yellow" + Write-ToLog "No Mods are implemented..." "Yellow" } } if ($DeletedMods -gt 0) { - Write-Log "$DeletedMods Mods deleted (not externally managed) from local path: $($WAUConfig.InstallLocation.TrimEnd(" ", "\"))\mods" "Red" + Write-ToLog "$DeletedMods Mods deleted (not externally managed) from local path: $($WAUConfig.InstallLocation.TrimEnd(" ", "\"))\mods" "Red" } } } @@ -180,12 +180,12 @@ if (Test-Network) { #Get White or Black list if ($WAUConfig.WAU_UseWhiteList -eq 1) { - Write-Log "WAU uses White List config" + Write-ToLog "WAU uses White List config" $toUpdate = Get-IncludedApps $UseWhiteList = $true } else { - Write-Log "WAU uses Black List config" + Write-ToLog "WAU uses Black List config" $toSkip = Get-ExcludedApps } @@ -194,7 +194,7 @@ if (Test-Network) { if ($UseWhiteList) { $WhiteList = $toUpdate.GetUpperBound(0) if ($null -eq $WhiteList) { - Write-Log "Critical: Whitelist doesn't exist in GPO, exiting..." "Red" + Write-ToLog "Critical: Whitelist doesn't exist in GPO, exiting..." "Red" New-Item "$WorkingDir\logs\error.txt" -Value "Whitelist doesn't exist in GPO" -Force Exit 1 } @@ -203,7 +203,7 @@ if (Test-Network) { else { $BlackList = $toSkip.GetUpperBound(0) if ($null -eq $BlackList) { - Write-Log "Critical: Blacklist doesn't exist in GPO, exiting..." "Red" + Write-ToLog "Critical: Blacklist doesn't exist in GPO, exiting..." "Red" New-Item "$WorkingDir\logs\error.txt" -Value "Blacklist doesn't exist in GPO" -Force Exit 1 } @@ -212,12 +212,12 @@ if (Test-Network) { } #Get outdated Winget packages - Write-Log "Checking application updates on Winget Repository..." "yellow" + Write-ToLog "Checking application updates on Winget Repository..." "yellow" $outdated = Get-WingetOutdatedApps #If something unusual happened if ($outdated -like "An unusual*") { - Write-Log "$outdated" "cyan" + Write-ToLog "$outdated" "cyan" $outdated = $False } @@ -236,7 +236,7 @@ if (Test-Network) { #Trick under user context when -BypassListForUsers is used if ($IsSystem -eq $false -and $WAUConfig.WAU_BypassListForUsers -eq $true) { - Write-Log "Bypass system list in user context is Enabled." + Write-ToLog "Bypass system list in user context is Enabled." $UseWhiteList = $false $toSkip = $null } @@ -250,11 +250,11 @@ if (Test-Network) { } #if current app version is unknown elseif ($($app.Version) -eq "Unknown") { - Write-Log "$($app.Name) : Skipped upgrade because current version is 'Unknown'" "Gray" + Write-ToLog "$($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" + Write-ToLog "$($app.Name) : Skipped upgrade because it is not in the included app list" "Gray" } } } @@ -267,22 +267,22 @@ if (Test-Network) { } #if current app version is unknown elseif ($($app.Version) -eq "Unknown") { - Write-Log "$($app.Name) : Skipped upgrade because current version is 'Unknown'" "Gray" + Write-ToLog "$($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" + Write-ToLog "$($app.Name) : Skipped upgrade because it is in the excluded app list" "Gray" } } } if ($InstallOK -gt 0) { - Write-Log "$InstallOK apps updated ! No more update." "Green" + Write-ToLog "$InstallOK apps updated ! No more update." "Green" } } if ($InstallOK -eq 0 -or !$InstallOK) { - Write-Log "No new update." "Green" + Write-ToLog "No new update." "Green" } #Check if any user is logged on if System and run User task (if installed) @@ -290,7 +290,7 @@ if (Test-Network) { #User check routine from: https://stackoverflow.com/questions/23219718/powershell-script-to-see-currently-logged-in-users-domain-and-machine-status $explorerprocesses = @(Get-WmiObject -Query "Select * FROM Win32_Process WHERE Name='explorer.exe'" -ErrorAction SilentlyContinue) If ($explorerprocesses.Count -eq 0) { - Write-Log "No explorer process found / Nobody interactively logged on..." + Write-ToLog "No explorer process found / Nobody interactively logged on..." } Else { #Run WAU in user context if the user task exist @@ -298,28 +298,28 @@ if (Test-Network) { if ($UserScheduledTask) { #Get Winget system apps to excape them befor running user context - Write-Log "User logged on, get a list of installed Winget apps in System context..." + Write-ToLog "User logged on, get a list of installed Winget apps in System context..." Get-WingetSystemApps #Run user context scheduled task - Write-Log "Starting WAU in User context" + Write-ToLog "Starting WAU in User context" Start-ScheduledTask $UserScheduledTask.TaskName -ErrorAction SilentlyContinue Exit 0 } elseif (!$UserScheduledTask) { - Write-Log "User context execution not installed..." + Write-ToLog "User context execution not installed..." } } } } else { - Write-Log "Critical: Winget not installed or detected, exiting..." "red" + Write-ToLog "Critical: Winget not installed or detected, exiting..." "red" New-Item "$WorkingDir\logs\error.txt" -Value "Winget not installed or detected" -Force - Write-Log "End of process!" "Cyan" + Write-ToLog "End of process!" "Cyan" Exit 1 } } #End -Write-Log "End of process!" "Cyan" +Write-ToLog "End of process!" "Cyan" Start-Sleep 3 diff --git a/Winget-AutoUpdate/functions/Get-AZCopy.ps1 b/Winget-AutoUpdate/functions/Get-AZCopy.ps1 index 7926291..e6f7d54 100644 --- a/Winget-AutoUpdate/functions/Get-AZCopy.ps1 +++ b/Winget-AutoUpdate/functions/Get-AZCopy.ps1 @@ -13,17 +13,17 @@ Function Get-AZCopy ($WingetUpdatePath) { if (Test-Path -Path "$WingetUpdatePath\azcopy.exe" -PathType Leaf) { $AZCopyCurrentVersion = & "$WingetUpdatePath\azcopy.exe" -v $AZCopyCurrentVersion = $AZCopyVersionRegex.Match($AZCopyCurrentVersion).Value - Write-Log "AZCopy version $AZCopyCurrentVersion found" + Write-ToLog "AZCopy version $AZCopyCurrentVersion found" } else { - Write-Log "AZCopy not already installed" + Write-ToLog "AZCopy not already installed" $AZCopyCurrentVersion = "0.0.0" } if (([version] $AZCopyCurrentVersion) -lt ([version] $AZCopyLatestVersion)) { - Write-Log "Installing version $AZCopyLatestVersion of AZCopy" + Write-ToLog "Installing version $AZCopyLatestVersion of AZCopy" Invoke-WebRequest -Uri $AZCopyLink -UseBasicParsing -OutFile "$WingetUpdatePath\azcopyv10.zip" - Write-Log "Extracting AZCopy zip file" + Write-ToLog "Extracting AZCopy zip file" Expand-archive -Path "$WingetUpdatePath\azcopyv10.zip" -Destinationpath "$WingetUpdatePath" -Force @@ -36,15 +36,15 @@ Function Get-AZCopy ($WingetUpdatePath) { $AZCopyEXEPath = $AZCopyPathSearch } - Write-Log "Copying 'azcopy.exe' to main folder" + Write-ToLog "Copying 'azcopy.exe' to main folder" Copy-Item "$AZCopyEXEPath\azcopy.exe" -Destination "$WingetUpdatePath\" - Write-Log "Removing temporary AZCopy files" + Write-ToLog "Removing temporary AZCopy files" Remove-Item -Path $AZCopyEXEPath -Recurse Remove-Item -Path "$WingetUpdatePath\azcopyv10.zip" $AZCopyCurrentVersion = & "$WingetUpdatePath\azcopy.exe" -v $AZCopyCurrentVersion = $AZCopyVersionRegex.Match($AZCopyCurrentVersion).Value - Write-Log "AZCopy version $AZCopyCurrentVersion installed" + Write-ToLog "AZCopy version $AZCopyCurrentVersion installed" } } \ No newline at end of file diff --git a/Winget-AutoUpdate/functions/Get-WAUAvailableVersion.ps1 b/Winget-AutoUpdate/functions/Get-WAUAvailableVersion.ps1 index 20fd1e9..0d3e535 100644 --- a/Winget-AutoUpdate/functions/Get-WAUAvailableVersion.ps1 +++ b/Winget-AutoUpdate/functions/Get-WAUAvailableVersion.ps1 @@ -6,7 +6,7 @@ function Get-WAUAvailableVersion { if ($WAUConfig.WAU_UpdatePrerelease -eq 1) { #Log - Write-log "WAU AutoUpdate Pre-release versions is Enabled" "Cyan" + Write-ToLog "WAU AutoUpdate Pre-release versions is Enabled" "Cyan" #Get latest pre-release info $WAUurl = 'https://api.github.com/repos/Romanitho/Winget-AutoUpdate/releases' diff --git a/Winget-AutoUpdate/functions/Get-WingetCmd.ps1 b/Winget-AutoUpdate/functions/Get-WingetCmd.ps1 index 7399b1f..3c4ab6d 100644 --- a/Winget-AutoUpdate/functions/Get-WingetCmd.ps1 +++ b/Winget-AutoUpdate/functions/Get-WingetCmd.ps1 @@ -21,7 +21,7 @@ Function Get-WingetCmd { $Script:Winget = "$WingetPath\winget.exe" } else { - Write-Log "Winget not installed or detected !" "Red" + Write-ToLog "Winget not installed or detected !" "Red" return $false } @@ -30,7 +30,7 @@ Function Get-WingetCmd { #Log Winget installed version $WingetVer = & $Winget --version - Write-Log "Winget Version: $WingetVer" + Write-ToLog "Winget Version: $WingetVer" return $true diff --git a/Winget-AutoUpdate/functions/Invoke-LogRotation.ps1 b/Winget-AutoUpdate/functions/Invoke-LogRotation.ps1 index 8699421..82edf17 100644 --- a/Winget-AutoUpdate/functions/Invoke-LogRotation.ps1 +++ b/Winget-AutoUpdate/functions/Invoke-LogRotation.ps1 @@ -1,4 +1,4 @@ -#Function to rotate the logs +#Function to rotate the logs function Invoke-LogRotation ($LogFile, $MaxLogFiles, $MaxLogSize) { <# @@ -73,17 +73,17 @@ function Invoke-LogRotation ($LogFile, $MaxLogFiles, $MaxLogSize) { #Log Header $Log = "##################################################`n# CHECK FOR APP UPDATES - $(Get-Date -Format (Get-culture).DateTimeFormat.ShortDatePattern)`n##################################################" $Log | out-file -filepath $LogFile -Append - Write-Log "Running in System context" + Write-ToLog "Running in System context" if ($ActivateGPOManagement) { - Write-Log "Activated WAU GPO Management detected, comparing..." + Write-ToLog "Activated WAU GPO Management detected, comparing..." if ($null -ne $ChangedSettings -and $ChangedSettings -ne 0) { - Write-Log "Changed settings detected and applied" "Yellow" + Write-ToLog "Changed settings detected and applied" "Yellow" } else { - Write-Log "No Changed settings detected" "Yellow" + Write-ToLog "No Changed settings detected" "Yellow" } } - Write-Log "Max Log Size reached: $MaxLogSize bytes - Rotated Logs" + Write-ToLog "Max Log Size reached: $MaxLogSize bytes - Rotated Logs" Return $True } diff --git a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 index 1f8b643..e423df7 100644 --- a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 +++ b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 @@ -3,15 +3,15 @@ function Invoke-PostUpdateActions { #log - Write-Log "Running Post Update actions:" "yellow" + Write-ToLog "Running Post Update actions:" "yellow" #Check if Intune Management Extension Logs folder and WAU-updates.log exists, make symlink if ((Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs") -and !(Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-updates.log")) { - Write-log "-> Creating SymLink for log file in Intune Management Extension log folder" "yellow" + Write-ToLog "-> Creating SymLink for log file in Intune Management Extension log folder" "yellow" New-Item -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-updates.log" -ItemType SymbolicLink -Value $LogFile -Force -ErrorAction SilentlyContinue | Out-Null } - Write-Log "-> Checking prerequisites..." "yellow" + Write-ToLog "-> Checking prerequisites..." "yellow" #Check if Visual C++ 2019 or 2022 installed $Visual2019 = "Microsoft Visual C++ 2015-2019 Redistributable*" @@ -27,25 +27,25 @@ function Invoke-PostUpdateActions { else { $OSArch = "x86" } - Write-Log "-> Downloading VC_redist.$OSArch.exe..." + Write-ToLog "-> Downloading VC_redist.$OSArch.exe..." $SourceURL = "https://aka.ms/vs/17/release/VC_redist.$OSArch.exe" $Installer = "$($WAUConfig.InstallLocation)\VC_redist.$OSArch.exe" $ProgressPreference = 'SilentlyContinue' Invoke-WebRequest $SourceURL -UseBasicParsing -OutFile (New-Item -Path $Installer -Force) - Write-Log "-> Installing VC_redist.$OSArch.exe..." + Write-ToLog "-> Installing VC_redist.$OSArch.exe..." Start-Process -FilePath $Installer -Args "/quiet /norestart" -Wait Remove-Item $Installer -ErrorAction Ignore - Write-Log "-> MS Visual C++ 2015-2022 installed successfully" "green" + Write-ToLog "-> MS Visual C++ 2015-2022 installed successfully" "green" } catch { - Write-Log "-> MS Visual C++ 2015-2022 installation failed." "red" + Write-ToLog "-> MS Visual C++ 2015-2022 installation failed." "red" } } else { - Write-Log "-> Prerequisites checked. OK" "green" + Write-ToLog "-> Prerequisites checked. OK" "green" } - Write-Log "-> Checking if Winget is installed/up to date" "yellow" + Write-ToLog "-> Checking if Winget is installed/up to date" "yellow" #Check Package Install $TestWinGet = Get-AppxProvisionedPackage -Online | Where-Object { $_.DisplayName -eq "Microsoft.DesktopAppInstaller" } @@ -53,25 +53,25 @@ function Invoke-PostUpdateActions { #Current: v1.4.10173 = 1.19.10173.0 = 2023.118.406.0 If ([Version]$TestWinGet.Version -ge "2023.118.406.0") { - Write-Log "-> WinGet is Installed/up to date" "green" + Write-ToLog "-> WinGet is Installed/up to date" "green" } Else { #Download WinGet MSIXBundle - Write-Log "-> Not installed/up to date. Downloading WinGet..." + Write-ToLog "-> Not installed/up to date. Downloading WinGet..." $WinGetURL = "https://github.com/microsoft/winget-cli/releases/download/v1.4.10173/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" $WebClient = New-Object System.Net.WebClient $WebClient.DownloadFile($WinGetURL, "$($WAUConfig.InstallLocation)\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle") #Install WinGet MSIXBundle try { - Write-Log "-> Installing Winget MSIXBundle for App Installer..." + Write-ToLog "-> Installing Winget MSIXBundle for App Installer..." Add-AppxProvisionedPackage -Online -PackagePath "$($WAUConfig.InstallLocation)\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -SkipLicense | Out-Null - Write-Log "-> Installed Winget MSIXBundle for App Installer" "green" + Write-ToLog "-> Installed Winget MSIXBundle for App Installer" "green" } catch { - Write-Log "-> Failed to intall Winget MSIXBundle for App Installer..." "red" + Write-ToLog "-> Failed to intall Winget MSIXBundle for App Installer..." "red" } #Remove WinGet MSIXBundle @@ -87,7 +87,7 @@ function Invoke-PostUpdateActions { & $WingetPath source reset --force #log - Write-Log "-> Winget sources reseted." "green" + Write-ToLog "-> Winget sources reseted." "green" } #Create WAU Regkey if not present @@ -106,7 +106,7 @@ function Invoke-PostUpdateActions { New-ItemProperty $regPath -Name WAU_UpdatePrerelease -Value 0 -PropertyType DWord -Force #log - Write-Log "-> $regPath created." "green" + Write-ToLog "-> $regPath created." "green" } #Fix Notif where WAU_NotificationLevel is not set $regNotif = Get-ItemProperty $regPath -Name WAU_NotificationLevel -ErrorAction SilentlyContinue @@ -114,7 +114,7 @@ function Invoke-PostUpdateActions { New-ItemProperty $regPath -Name WAU_NotificationLevel -Value Full -Force #log - Write-Log "-> Notification level setting was missing. Fixed with 'Full' option." + Write-ToLog "-> Notification level setting was missing. Fixed with 'Full' option." } #Set WAU_MaxLogFiles/WAU_MaxLogSize if not set @@ -124,7 +124,7 @@ function Invoke-PostUpdateActions { New-ItemProperty $regPath -Name WAU_MaxLogSize -Value 1048576 -PropertyType DWord -Force | Out-Null #log - Write-Log "-> MaxLogFiles/MaxLogSize setting was missing. Fixed with 3/1048576 (in bytes, default is 1048576 = 1 MB)." + Write-ToLog "-> MaxLogFiles/MaxLogSize setting was missing. Fixed with 3/1048576 (in bytes, default is 1048576 = 1 MB)." } #Set WAU_ListPath if not set @@ -133,7 +133,7 @@ function Invoke-PostUpdateActions { New-ItemProperty $regPath -Name WAU_ListPath -Force | Out-Null #log - Write-Log "-> ListPath setting was missing. Fixed with empty string." + Write-ToLog "-> ListPath setting was missing. Fixed with empty string." } #Set WAU_ModsPath if not set @@ -142,20 +142,20 @@ function Invoke-PostUpdateActions { New-ItemProperty $regPath -Name WAU_ModsPath -Force | Out-Null #log - Write-Log "-> ModsPath setting was missing. Fixed with empty string." + Write-ToLog "-> ModsPath setting was missing. Fixed with empty string." } #Security check - Write-Log "-> Checking Mods Directory:" "yellow" + Write-ToLog "-> Checking Mods Directory:" "yellow" $Protected = Invoke-ModsProtect "$($WAUConfig.InstallLocation)\mods" if ($Protected -eq $True) { - Write-Log "-> The mods directory is now secured!" "green" + Write-ToLog "-> The mods directory is now secured!" "green" } elseif ($Protected -eq $False) { - Write-Log "-> The mods directory was already secured!" "green" + Write-ToLog "-> The mods directory was already secured!" "green" } else { - Write-Log "-> Error: The mods directory couldn't be verified as secured!" "red" + Write-ToLog "-> Error: The mods directory couldn't be verified as secured!" "red" } #Convert about.xml if exists (previous WAU versions) to reg @@ -170,7 +170,7 @@ function Invoke-PostUpdateActions { Remove-Item $WAUAboutPath -Force -Confirm:$false #log - Write-Log "-> $WAUAboutPath converted." "green" + Write-ToLog "-> $WAUAboutPath converted." "green" } #Convert config.xml if exists (previous WAU versions) to reg @@ -186,7 +186,7 @@ function Invoke-PostUpdateActions { Remove-Item $WAUConfigPath -Force -Confirm:$false #log - Write-Log "-> $WAUConfigPath converted." "green" + Write-ToLog "-> $WAUConfigPath converted." "green" } #Remove old functions @@ -200,7 +200,7 @@ function Invoke-PostUpdateActions { Remove-Item $FileName -Force -Confirm:$false #log - Write-Log "-> $FileName removed." "green" + Write-ToLog "-> $FileName removed." "green" } } @@ -211,6 +211,6 @@ function Invoke-PostUpdateActions { $Script:WAUConfig = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" #log - Write-Log "Post Update actions finished" "green" + Write-ToLog "Post Update actions finished" "green" } diff --git a/Winget-AutoUpdate/functions/Test-ModsPath.ps1 b/Winget-AutoUpdate/functions/Test-ModsPath.ps1 index 65841f5..9f468b1 100644 --- a/Winget-AutoUpdate/functions/Test-ModsPath.ps1 +++ b/Winget-AutoUpdate/functions/Test-ModsPath.ps1 @@ -136,12 +136,12 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath, $AzureBlobSASURL) { } # If Path is Azure Blob elseif ($ExternalMods -like "AzureBlob") { - Write-Log "Azure Blob Storage set as mod source" - Write-Log "Checking AZCopy" + Write-ToLog "Azure Blob Storage set as mod source" + Write-ToLog "Checking AZCopy" Get-AZCopy $WingetUpdatePath #Safety check to make sure we really do have azcopy.exe and a Blob URL if ((Test-Path -Path "$WingetUpdatePath\azcopy.exe" -PathType Leaf) -and ($null -ne $AzureBlobSASURL)) { - Write-Log "Syncing Blob storage with local storage" + Write-ToLog "Syncing Blob storage with local storage" $AZCopySyncOutput = & $WingetUpdatePath\azcopy.exe sync "$AzureBlobSASURL" "$LocalMods" --from-to BlobLocal --delete-destination=true $AZCopyOutputLines = $AZCopySyncOutput.Split([Environment]::NewLine) @@ -163,12 +163,12 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath, $AzureBlobSASURL) { } if ($AZCopySyncErrorRegex.Match($_).Value) { - Write-Log "AZCopy Sync Error! $_" + Write-ToLog "AZCopy Sync Error! $_" } } } else { - Write-Log "Error 'azcopy.exe' or SAS Token not found!" + Write-ToLog "Error 'azcopy.exe' or SAS Token not found!" } return $ModsUpdated, $DeletedMods diff --git a/Winget-AutoUpdate/functions/Test-Network.ps1 b/Winget-AutoUpdate/functions/Test-Network.ps1 index 7478ae7..5e4fc4f 100644 --- a/Winget-AutoUpdate/functions/Test-Network.ps1 +++ b/Winget-AutoUpdate/functions/Test-Network.ps1 @@ -9,7 +9,7 @@ function Test-Network { $ProgressPreference = 'SilentlyContinue' #Test connectivity during 30 min then timeout - Write-Log "Checking internet connection..." "Yellow" + Write-ToLog "Checking internet connection..." "Yellow" While ($timeout -lt 1800) { $URLtoTest = "https://raw.githubusercontent.com/Romanitho/Winget-AutoUpdate/main/LICENSE" @@ -17,7 +17,7 @@ function Test-Network { if ($URLcontent -like "*MIT License*") { - Write-Log "Connected !" "Green" + Write-ToLog "Connected !" "Green" #Check for metered connection [void][Windows.Networking.Connectivity.NetworkInformation, Windows, ContentType = WindowsRuntime] @@ -25,17 +25,17 @@ function Test-Network { if ($cost.ApproachingDataLimit -or $cost.OverDataLimit -or $cost.Roaming -or $cost.BackgroundDataUsageRestricted -or ($cost.NetworkCostType -ne "Unrestricted")) { - Write-Log "Metered connection detected." "Yellow" + Write-ToLog "Metered connection detected." "Yellow" if ($WAUConfig.WAU_DoNotRunOnMetered -eq 1) { - Write-Log "WAU is configured to bypass update checking on metered connection" + Write-ToLog "WAU is configured to bypass update checking on metered connection" return $false } else { - Write-Log "WAU is configured to force update checking on metered connection" + Write-ToLog "WAU is configured to force update checking on metered connection" return $true } @@ -56,7 +56,7 @@ function Test-Network { #Send Warning Notif if no connection for 5 min if ($timeout -eq 300) { #Log - Write-Log "Notify 'No connection' sent." "Yellow" + Write-ToLog "Notify 'No connection' sent." "Yellow" #Notif $Title = $NotifLocale.local.outputs.output[0].title @@ -71,7 +71,7 @@ function Test-Network { } #Send Timeout Notif if no connection for 30 min - Write-Log "Timeout. No internet connection !" "Red" + Write-ToLog "Timeout. No internet connection !" "Red" #Notif $Title = $NotifLocale.local.outputs.output[1].title diff --git a/Winget-AutoUpdate/functions/Update-App.ps1 b/Winget-AutoUpdate/functions/Update-App.ps1 index 5928308..95b3064 100644 --- a/Winget-AutoUpdate/functions/Update-App.ps1 +++ b/Winget-AutoUpdate/functions/Update-App.ps1 @@ -9,7 +9,7 @@ Function Update-App ($app) { } #Send available update notification - Write-Log "Updating $($app.Name) from $($app.Version) to $($app.AvailableVersion)..." "Cyan" + Write-ToLog "Updating $($app.Name) from $($app.Version) to $($app.AvailableVersion)..." "Cyan" $Title = $NotifLocale.local.outputs.output[2].title -f $($app.Name) $Message = $NotifLocale.local.outputs.output[2].message -f $($app.Version), $($app.AvailableVersion) $MessageType = "info" @@ -20,26 +20,26 @@ Function Update-App ($app) { $ModsPreInstall, $ModsOverride, $ModsUpgrade, $ModsInstall, $ModsInstalled = Test-Mods $($app.Id) #Winget upgrade - Write-Log "########## WINGET UPGRADE PROCESS STARTS FOR APPLICATION ID '$($App.Id)' ##########" "Gray" + Write-ToLog "########## WINGET UPGRADE PROCESS STARTS FOR APPLICATION ID '$($App.Id)' ##########" "Gray" #If PreInstall script exist if ($ModsPreInstall) { - Write-Log "Modifications for $($app.Id) before upgrade are being applied..." "Yellow" + Write-ToLog "Modifications for $($app.Id) before upgrade are being applied..." "Yellow" & "$ModsPreInstall" } #Run Winget Upgrade command if ($ModsOverride) { - Write-Log "-> Running (overriding default): Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements --override $ModsOverride" + Write-ToLog "-> Running (overriding default): Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements --override $ModsOverride" & $Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements --override $ModsOverride | Tee-Object -file $LogFile -Append } else { - Write-Log "-> Running: Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements -h" + Write-ToLog "-> Running: Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements -h" & $Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append } if ($ModsUpgrade) { - Write-Log "Modifications for $($app.Id) during upgrade are being applied..." "Yellow" + Write-ToLog "Modifications for $($app.Id) during upgrade are being applied..." "Yellow" & "$ModsUpgrade" } @@ -53,25 +53,25 @@ Function Update-App ($app) { #Test for a Pending Reboot (Component Based Servicing/WindowsUpdate/CCM_ClientUtilities) $PendingReboot = Test-PendingReboot if ($PendingReboot -eq $true) { - Write-Log "-> A Pending Reboot lingers and probably prohibited $($app.Name) from upgrading...`n-> ...an install for $($app.Name) is NOT executed!" "Red" + Write-ToLog "-> A Pending Reboot lingers and probably prohibited $($app.Name) from upgrading...`n-> ...an install for $($app.Name) is NOT executed!" "Red" $FailedToUpgrade = $true break } #If app failed to upgrade, run Install command - Write-Log "-> An upgrade for $($app.Name) failed, now trying an install instead..." "Yellow" + Write-ToLog "-> An upgrade for $($app.Name) failed, now trying an install instead..." "Yellow" if ($ModsOverride) { - Write-Log "-> Running (overriding default): Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements --override $ModsOverride" + Write-ToLog "-> Running (overriding default): Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements --override $ModsOverride" & $Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements --override $ModsOverride | Tee-Object -file $LogFile -Append } else { - Write-Log "-> Running: Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements -h" + Write-ToLog "-> Running: Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements -h" & $Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append } if ($ModsInstall) { - Write-Log "Modifications for $($app.Id) during install are being applied..." "Yellow" + Write-ToLog "Modifications for $($app.Id) during install are being applied..." "Yellow" & "$ModsInstall" } @@ -87,18 +87,18 @@ Function Update-App ($app) { if ($FailedToUpgrade -eq $false) { if ($ModsInstalled) { - Write-Log "Modifications for $($app.Id) after upgrade/install are being applied..." "Yellow" + Write-ToLog "Modifications for $($app.Id) after upgrade/install are being applied..." "Yellow" & "$ModsInstalled" } } - Write-Log "########## WINGET UPGRADE PROCESS FINISHED FOR APPLICATION ID '$($App.Id)' ##########" "Gray" + Write-ToLog "########## WINGET UPGRADE PROCESS FINISHED FOR APPLICATION ID '$($App.Id)' ##########" "Gray" #Notify installation if ($FailedToUpgrade -eq $false) { #Send success updated app notification - Write-Log "$($app.Name) updated to $($app.AvailableVersion) !" "Green" + Write-ToLog "$($app.Name) updated to $($app.AvailableVersion) !" "Green" #Send Notif $Title = $NotifLocale.local.outputs.output[3].title -f $($app.Name) @@ -113,7 +113,7 @@ Function Update-App ($app) { else { #Send failed updated app notification - Write-Log "$($app.Name) update failed." "Red" + Write-ToLog "$($app.Name) update failed." "Red" #Send Notif $Title = $NotifLocale.local.outputs.output[4].title -f $($app.Name) diff --git a/Winget-AutoUpdate/functions/Update-WAU.ps1 b/Winget-AutoUpdate/functions/Update-WAU.ps1 index 6fe3aa2..0b2f22f 100644 --- a/Winget-AutoUpdate/functions/Update-WAU.ps1 +++ b/Winget-AutoUpdate/functions/Update-WAU.ps1 @@ -19,24 +19,24 @@ function Update-WAU { New-Item $ZipFile -ItemType File -Force | Out-Null #Download the zip - Write-Log "Downloading the GitHub Repository version $WAUAvailableVersion" "Cyan" + Write-ToLog "Downloading the GitHub Repository version $WAUAvailableVersion" "Cyan" Invoke-RestMethod -Uri "https://github.com/Romanitho/Winget-AutoUpdate/archive/refs/tags/v$($WAUAvailableVersion).zip/" -OutFile $ZipFile #Extract Zip File - Write-Log "Unzipping the WAU GitHub Repository" "Cyan" + Write-ToLog "Unzipping the WAU GitHub Repository" "Cyan" $location = "$WorkingDir\WAU_update" Expand-Archive -Path $ZipFile -DestinationPath $location -Force Get-ChildItem -Path $location -Recurse | Unblock-File #Update scritps - Write-Log "Updating WAU" "Yellow" + Write-ToLog "Updating WAU" "Yellow" $TempPath = (Resolve-Path "$location\*\Winget-AutoUpdate\")[0].Path if ($TempPath) { Copy-Item -Path "$TempPath\*" -Destination "$WorkingDir\" -Exclude "icons" -Recurse -Force } #Remove update zip file and update temp folder - Write-Log "Done. Cleaning temp files" "Cyan" + Write-ToLog "Done. Cleaning temp files" "Cyan" Remove-Item -Path $ZipFile -Force -ErrorAction SilentlyContinue Remove-Item -Path $location -Recurse -Force -ErrorAction SilentlyContinue @@ -49,14 +49,14 @@ function Update-WAU { $WAUConfig | New-ItemProperty -Name WAU_PostUpdateActions -Value 1 -Force #Send success Notif - Write-Log "WAU Update completed." "Green" + Write-ToLog "WAU Update completed." "Green" $Title = $NotifLocale.local.outputs.output[3].title -f "Winget-AutoUpdate" $Message = $NotifLocale.local.outputs.output[3].message -f $WAUAvailableVersion $MessageType = "success" Start-NotifTask -Title $Title -Message $Message -MessageType $MessageType -Button1Action $OnClickAction -Button1Text $Button1Text #Rerun with newer version - Write-Log "Re-run WAU" + Write-ToLog "Re-run WAU" Start-Process powershell -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command `"$WorkingDir\winget-upgrade.ps1`"" exit @@ -70,7 +70,7 @@ function Update-WAU { $Message = $NotifLocale.local.outputs.output[4].message $MessageType = "error" Start-NotifTask -Title $Title -Message $Message -MessageType $MessageType -Button1Action $OnClickAction -Button1Text $Button1Text - Write-Log "WAU Update failed" "Red" + Write-ToLog "WAU Update failed" "Red" } diff --git a/Winget-AutoUpdate/functions/Write-Log.ps1 b/Winget-AutoUpdate/functions/Write-ToLog.ps1 similarity index 80% rename from Winget-AutoUpdate/functions/Write-Log.ps1 rename to Winget-AutoUpdate/functions/Write-ToLog.ps1 index e30f6f1..db1116e 100644 --- a/Winget-AutoUpdate/functions/Write-Log.ps1 +++ b/Winget-AutoUpdate/functions/Write-ToLog.ps1 @@ -1,6 +1,6 @@ #Write to Log Function -function Write-Log ($LogMsg, $LogColor = "White") { +function Write-ToLog ($LogMsg, $LogColor = "White") { #Get log $Log = "$(Get-Date -UFormat "%T") - $LogMsg" From cd33a8cca2530dbe8a8bd2e9fac5adc6d03138dd Mon Sep 17 00:00:00 2001 From: Fabian Seitz Date: Sat, 1 Apr 2023 16:14:31 +0200 Subject: [PATCH 056/131] uncomment unused variables --- Winget-AutoUpdate/User-Run.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Winget-AutoUpdate/User-Run.ps1 b/Winget-AutoUpdate/User-Run.ps1 index 13e0974..5c87ae3 100644 --- a/Winget-AutoUpdate/User-Run.ps1 +++ b/Winget-AutoUpdate/User-Run.ps1 @@ -44,9 +44,9 @@ Get-NotifLocale #Set common variables $OnClickAction = "$WorkingDir\logs\updates.log" $Button1Text = $NotifLocale.local.outputs.output[11].message -$Title = "Winget-AutoUpdate (WAU)" -$Balise = "Winget-AutoUpdate (WAU)" -$UserRun = $True +#$Title = "Winget-AutoUpdate (WAU)" +#$Balise = "Winget-AutoUpdate (WAU)" +#$UserRun = $True if ($Logs) { if (Test-Path "$WorkingDir\logs\updates.log") { From 75289efd3d69ffc7b60e050eb5778bea67aac58b Mon Sep 17 00:00:00 2001 From: Fabian Seitz Date: Mon, 3 Apr 2023 11:41:53 +0200 Subject: [PATCH 057/131] do not uncomment variables used by other files --- Winget-AutoUpdate/User-Run.ps1 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Winget-AutoUpdate/User-Run.ps1 b/Winget-AutoUpdate/User-Run.ps1 index 5c87ae3..e3f8151 100644 --- a/Winget-AutoUpdate/User-Run.ps1 +++ b/Winget-AutoUpdate/User-Run.ps1 @@ -44,9 +44,10 @@ Get-NotifLocale #Set common variables $OnClickAction = "$WorkingDir\logs\updates.log" $Button1Text = $NotifLocale.local.outputs.output[11].message -#$Title = "Winget-AutoUpdate (WAU)" -#$Balise = "Winget-AutoUpdate (WAU)" -#$UserRun = $True +#The variables afterwards are used within Start-NotifTask.ps1 +$Title = "Winget-AutoUpdate (WAU)" +$Balise = "Winget-AutoUpdate (WAU)" +$UserRun = $True if ($Logs) { if (Test-Path "$WorkingDir\logs\updates.log") { From 6aecf425e64f4d2ecda4292404a9ff3e8bdfea79 Mon Sep 17 00:00:00 2001 From: Fabian Seitz Date: Mon, 3 Apr 2023 11:47:32 +0200 Subject: [PATCH 058/131] PSUseDeclaredVarsMoreThanAssignments non blocking error --- .github/.powershell-psscriptanalyzer.psd1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/.powershell-psscriptanalyzer.psd1 b/.github/.powershell-psscriptanalyzer.psd1 index 21f77be..84269ea 100644 --- a/.github/.powershell-psscriptanalyzer.psd1 +++ b/.github/.powershell-psscriptanalyzer.psd1 @@ -14,6 +14,7 @@ 'PSAvoidUsingWMICmdlet', 'PSReviewUnusedParameter', 'PSUseDeclaredVarsMoreThanAssignment', - 'PSUseShouldProcessForStateChangingFunctions' + 'PSUseShouldProcessForStateChangingFunctions', + 'PSUseDeclaredVarsMoreThanAssignments' ) } \ No newline at end of file From 55c4efdc69a6f6236ab5b3fa10117918d0c9de7a Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Fri, 7 Apr 2023 13:29:55 +0200 Subject: [PATCH 059/131] Variables from User-Run moved --- Winget-AutoUpdate/User-Run.ps1 | 4 ---- Winget-AutoUpdate/functions/Start-NotifTask.ps1 | 7 +++++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Winget-AutoUpdate/User-Run.ps1 b/Winget-AutoUpdate/User-Run.ps1 index e3f8151..9ecef3b 100644 --- a/Winget-AutoUpdate/User-Run.ps1 +++ b/Winget-AutoUpdate/User-Run.ps1 @@ -44,10 +44,6 @@ Get-NotifLocale #Set common variables $OnClickAction = "$WorkingDir\logs\updates.log" $Button1Text = $NotifLocale.local.outputs.output[11].message -#The variables afterwards are used within Start-NotifTask.ps1 -$Title = "Winget-AutoUpdate (WAU)" -$Balise = "Winget-AutoUpdate (WAU)" -$UserRun = $True if ($Logs) { if (Test-Path "$WorkingDir\logs\updates.log") { diff --git a/Winget-AutoUpdate/functions/Start-NotifTask.ps1 b/Winget-AutoUpdate/functions/Start-NotifTask.ps1 index e78062d..d01e128 100644 --- a/Winget-AutoUpdate/functions/Start-NotifTask.ps1 +++ b/Winget-AutoUpdate/functions/Start-NotifTask.ps1 @@ -14,6 +14,13 @@ function Start-NotifTask { [Switch]$ButtonDismiss = $false ) + $caller = Get-ChildItem $MyInvocation.PSCommandPath | Select-Object -Expand Name + if ($caller -eq "User-Run.ps1") { + $Title = "Winget-AutoUpdate (WAU)" + $Balise = "Winget-AutoUpdate (WAU)" + $UserRun = $True + } + if (($WAUConfig.WAU_NotificationLevel -eq "Full") -or ($WAUConfig.WAU_NotificationLevel -eq "SuccessOnly" -and $MessageType -eq "Success") -or ($UserRun)) { # XML Toast template creation From 1eddc6ccc42f495ed7426e36750a353d31a7d52b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Apr 2023 07:02:54 +0000 Subject: [PATCH 060/131] Bump peter-evans/create-pull-request from 4 to 5 Bumps [peter-evans/create-pull-request](https://github.com/peter-evans/create-pull-request) from 4 to 5. - [Release notes](https://github.com/peter-evans/create-pull-request/releases) - [Commits](https://github.com/peter-evans/create-pull-request/compare/v4...v5) --- updated-dependencies: - dependency-name: peter-evans/create-pull-request dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/mega-linter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mega-linter.yml b/.github/workflows/mega-linter.yml index ff9d2c4..84304b1 100644 --- a/.github/workflows/mega-linter.yml +++ b/.github/workflows/mega-linter.yml @@ -67,7 +67,7 @@ jobs: - name: Create Pull Request with applied fixes id: cpr if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'pull_request' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix') - uses: peter-evans/create-pull-request@v4 + uses: peter-evans/create-pull-request@v5 with: token: ${{ secrets.GITHUB_TOKEN }} commit-message: "[MegaLinter] Apply linters automatic fixes" From b9139542cedd3df959d86de0295cd5798496fdf6 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Mon, 10 Apr 2023 21:10:15 +0200 Subject: [PATCH 061/131] Better by Romain --- Winget-AutoUpdate/User-Run.ps1 | 10 +++++----- Winget-AutoUpdate/functions/Start-NotifTask.ps1 | 10 ++-------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/Winget-AutoUpdate/User-Run.ps1 b/Winget-AutoUpdate/User-Run.ps1 index 9ecef3b..176fb26 100644 --- a/Winget-AutoUpdate/User-Run.ps1 +++ b/Winget-AutoUpdate/User-Run.ps1 @@ -53,7 +53,7 @@ if ($Logs) { #Not available yet $Message = $NotifLocale.local.outputs.output[5].message $MessageType = "warning" - Start-NotifTask -Message $Message -MessageType $MessageType + Start-NotifTask -Message $Message -MessageType $MessageType -UserRun } } elseif ($Help) { @@ -65,7 +65,7 @@ else { if (Test-WAUisRunning) { $Message = $NotifLocale.local.outputs.output[8].message $MessageType = "warning" - Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss + Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss -UserRun break } #Run scheduled task @@ -73,7 +73,7 @@ else { #Starting check - Send notification $Message = $NotifLocale.local.outputs.output[6].message $MessageType = "info" - Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss + Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss -UserRun #Sleep until the task is done While (Test-WAUisRunning) { Start-Sleep 3 @@ -91,12 +91,12 @@ else { $MessageType = "success" $Message = $NotifLocale.local.outputs.output[9].message } - Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss + Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss -UserRun } catch { #Check failed - Just send notification $Message = $NotifLocale.local.outputs.output[7].message $MessageType = "error" - Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss + Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss -UserRun } } diff --git a/Winget-AutoUpdate/functions/Start-NotifTask.ps1 b/Winget-AutoUpdate/functions/Start-NotifTask.ps1 index d01e128..6ffae41 100644 --- a/Winget-AutoUpdate/functions/Start-NotifTask.ps1 +++ b/Winget-AutoUpdate/functions/Start-NotifTask.ps1 @@ -11,16 +11,10 @@ function Start-NotifTask { [String]$Body, [String]$Button1Text, [String]$Button1Action, - [Switch]$ButtonDismiss = $false + [Switch]$ButtonDismiss = $false, + [Switch]$UserRun = $false ) - $caller = Get-ChildItem $MyInvocation.PSCommandPath | Select-Object -Expand Name - if ($caller -eq "User-Run.ps1") { - $Title = "Winget-AutoUpdate (WAU)" - $Balise = "Winget-AutoUpdate (WAU)" - $UserRun = $True - } - if (($WAUConfig.WAU_NotificationLevel -eq "Full") -or ($WAUConfig.WAU_NotificationLevel -eq "SuccessOnly" -and $MessageType -eq "Success") -or ($UserRun)) { # XML Toast template creation From 8ce47b3560ac9b9472603d6cb6b6b750a6de0752 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Wed, 12 Apr 2023 14:11:31 +0200 Subject: [PATCH 062/131] Create AutoCreatePreVersion.yml --- .github/workflows/AutoCreatePreVersion.yml | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/AutoCreatePreVersion.yml diff --git a/.github/workflows/AutoCreatePreVersion.yml b/.github/workflows/AutoCreatePreVersion.yml new file mode 100644 index 0000000..a3af602 --- /dev/null +++ b/.github/workflows/AutoCreatePreVersion.yml @@ -0,0 +1,40 @@ +name: Auto Create Pre-Release Version + +on: + workflow_dispatch: + pull_request: + types: + - closed + +jobs: + build: + name: Create Release Asset + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + lfs: 'true' + - name: Build project # This would actually build your project, using zip for an example artifact + run: | + zip -r WAU Winget-AutoUpdate/* + zip -r WAU Winget-AutoUpdate-Install.ps1 + zip -r WAU excluded_apps.txt + zip -r WAU install.bat + zip -r WAU uninstall.bat + + - name: Auto Increment Semver Action + uses: MCKanpolat/auto-semver-action@v1 + id: versioning + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + + - uses: "marvinpinto/action-automatic-releases@latest" + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + automatic_release_tag: "v${{ steps.versioning.outputs.version }}" + prerelease: true + title: "v${{ steps.versioning.outputs.version }}" + files: | + WAU.zip + From 899d79142f9682bfc5de31a2027cc77089ed673f Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Wed, 12 Apr 2023 14:13:17 +0200 Subject: [PATCH 063/131] Update AutoCreatePreVersion.yml --- .github/workflows/AutoCreatePreVersion.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/AutoCreatePreVersion.yml b/.github/workflows/AutoCreatePreVersion.yml index a3af602..47c01e4 100644 --- a/.github/workflows/AutoCreatePreVersion.yml +++ b/.github/workflows/AutoCreatePreVersion.yml @@ -1,7 +1,6 @@ name: Auto Create Pre-Release Version on: - workflow_dispatch: pull_request: types: - closed From b35243f9fe607eae812b4ead45b7e4474d6c83b1 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Wed, 12 Apr 2023 14:30:51 +0200 Subject: [PATCH 064/131] Update AutoCreatePreVersion.yml --- .github/workflows/AutoCreatePreVersion.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/AutoCreatePreVersion.yml b/.github/workflows/AutoCreatePreVersion.yml index 47c01e4..7805708 100644 --- a/.github/workflows/AutoCreatePreVersion.yml +++ b/.github/workflows/AutoCreatePreVersion.yml @@ -4,6 +4,9 @@ on: pull_request: types: - closed + +permissions: + contents: write jobs: build: From c066766e4f47e89fe70cf4eee821f68c19461448 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Wed, 12 Apr 2023 14:34:23 +0200 Subject: [PATCH 065/131] Update AutoCreatePreVersion.yml --- .github/workflows/AutoCreatePreVersion.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/AutoCreatePreVersion.yml b/.github/workflows/AutoCreatePreVersion.yml index 7805708..d657352 100644 --- a/.github/workflows/AutoCreatePreVersion.yml +++ b/.github/workflows/AutoCreatePreVersion.yml @@ -1,6 +1,7 @@ name: Auto Create Pre-Release Version on: + workflow_dispatch: pull_request: types: - closed From 91a09bd0f1cf7fce99ed125dcffea8f5f6ab0fd9 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Wed, 12 Apr 2023 14:56:47 +0200 Subject: [PATCH 066/131] Update AutoCreatePreVersion.yml --- .github/workflows/AutoCreatePreVersion.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/AutoCreatePreVersion.yml b/.github/workflows/AutoCreatePreVersion.yml index d657352..a8e012d 100644 --- a/.github/workflows/AutoCreatePreVersion.yml +++ b/.github/workflows/AutoCreatePreVersion.yml @@ -31,6 +31,11 @@ jobs: id: versioning with: github_token: ${{ secrets.GITHUB_TOKEN }} + + - uses: "finnp/create-file-action@master" + env: + FILE_NAME: "Winget-AutoUpdate/Winget-AutoUpdate/Version.txt" + FILE_DATA: "${{ steps.versioning.outputs.version }}" - uses: "marvinpinto/action-automatic-releases@latest" with: From 7731733eac2fd0461a9a1af3f3de88cb1b8eadd3 Mon Sep 17 00:00:00 2001 From: romanitho <96626929+Romanitho@users.noreply.github.com> Date: Wed, 12 Apr 2023 16:25:56 +0200 Subject: [PATCH 067/131] Minor changes for automation --- .github/workflows/AutoCreatePreVersion.yml | 44 +++++++++++++--------- Winget-AutoUpdate-Install.ps1 | 9 +++-- Winget-AutoUpdate/Version.txt | 1 + 3 files changed, 34 insertions(+), 20 deletions(-) create mode 100644 Winget-AutoUpdate/Version.txt diff --git a/.github/workflows/AutoCreatePreVersion.yml b/.github/workflows/AutoCreatePreVersion.yml index a8e012d..8d9d2fe 100644 --- a/.github/workflows/AutoCreatePreVersion.yml +++ b/.github/workflows/AutoCreatePreVersion.yml @@ -5,7 +5,7 @@ on: pull_request: types: - closed - + permissions: contents: write @@ -17,26 +17,37 @@ jobs: - name: Checkout code uses: actions/checkout@v3 with: - lfs: 'true' - - name: Build project # This would actually build your project, using zip for an example artifact + lfs: 'true' + + - name: Auto Increment Semver Action + uses: MCKanpolat/auto-semver-action@v1 + id: versioning + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Overwrite Version.txt file + uses: "DamianReeves/write-file-action@master" + with: + path: Winget-AutoUpdate/Winget-AutoUpdate/Version.txt + write-mode: overwrite + contents: ${{ steps.versioning.outputs.version }} + + - name: Commit & Push + uses: Andro999b/push@v1.3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: main + force: true + message: 'Changed version to ${{ steps.versioning.outputs.version }}' + + - name: Build project run: | zip -r WAU Winget-AutoUpdate/* zip -r WAU Winget-AutoUpdate-Install.ps1 zip -r WAU excluded_apps.txt zip -r WAU install.bat zip -r WAU uninstall.bat - - - name: Auto Increment Semver Action - uses: MCKanpolat/auto-semver-action@v1 - id: versioning - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - - - uses: "finnp/create-file-action@master" - env: - FILE_NAME: "Winget-AutoUpdate/Winget-AutoUpdate/Version.txt" - FILE_DATA: "${{ steps.versioning.outputs.version }}" - + - uses: "marvinpinto/action-automatic-releases@latest" with: repo_token: "${{ secrets.GITHUB_TOKEN }}" @@ -44,5 +55,4 @@ jobs: prerelease: true title: "v${{ steps.versioning.outputs.version }}" files: | - WAU.zip - + WAU.zip \ No newline at end of file diff --git a/Winget-AutoUpdate-Install.ps1 b/Winget-AutoUpdate-Install.ps1 index c34d868..c6054e2 100644 --- a/Winget-AutoUpdate-Install.ps1 +++ b/Winget-AutoUpdate-Install.ps1 @@ -115,9 +115,6 @@ param( [Parameter(Mandatory = $False)] [int64] $MaxLogSize = 1048576 # in bytes, default is 1048576 = 1 MB ) -<# APP INFO #> - -$WAUVersion = "1.17.2" <# FUNCTIONS #> @@ -515,6 +512,12 @@ function Add-Shortcut ($Target, $Shortcut, $Arguments, $Icon, $Description) { $Shortcut.Save() } + +<# APP INFO #> + +$WAUVersion = Get-Content "$PSScriptRoot\Winget-AutoUpdate\Version.txt" -ErrorAction SilentlyContinue + + <# MAIN #> #If running as a 32-bit process on an x64 system, re-launch as a 64-bit process diff --git a/Winget-AutoUpdate/Version.txt b/Winget-AutoUpdate/Version.txt new file mode 100644 index 0000000..282f354 --- /dev/null +++ b/Winget-AutoUpdate/Version.txt @@ -0,0 +1 @@ +1.14.3 \ No newline at end of file From 78ee089c8701ff866477f44caa5a00baf13f2dce Mon Sep 17 00:00:00 2001 From: romanitho <96626929+Romanitho@users.noreply.github.com> Date: Wed, 12 Apr 2023 16:39:24 +0200 Subject: [PATCH 068/131] Remove version file post install --- Winget-AutoUpdate-Install.ps1 | 1 + Winget-AutoUpdate/Version.txt | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Winget-AutoUpdate-Install.ps1 b/Winget-AutoUpdate-Install.ps1 index c6054e2..fe37eca 100644 --- a/Winget-AutoUpdate-Install.ps1 +++ b/Winget-AutoUpdate-Install.ps1 @@ -552,5 +552,6 @@ else { Uninstall-WingetAutoUpdate } +Remove-Item "$WingetUpdatePath\Version.txt" -Force Write-host "`nEnd of process." -ForegroundColor Cyan Start-Sleep 3 diff --git a/Winget-AutoUpdate/Version.txt b/Winget-AutoUpdate/Version.txt index 282f354..021c75e 100644 --- a/Winget-AutoUpdate/Version.txt +++ b/Winget-AutoUpdate/Version.txt @@ -1 +1 @@ -1.14.3 \ No newline at end of file +1.17.3 \ No newline at end of file From 0fa992f5a50c9dadf973b31b9dcf87ff3423e0ff Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 12 Apr 2023 14:49:24 +0000 Subject: [PATCH 069/131] Changed version to 1.17.4 --- Winget-AutoUpdate/Winget-AutoUpdate/Version.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 Winget-AutoUpdate/Winget-AutoUpdate/Version.txt diff --git a/Winget-AutoUpdate/Winget-AutoUpdate/Version.txt b/Winget-AutoUpdate/Winget-AutoUpdate/Version.txt new file mode 100644 index 0000000..250f359 --- /dev/null +++ b/Winget-AutoUpdate/Winget-AutoUpdate/Version.txt @@ -0,0 +1 @@ +1.17.4 \ No newline at end of file From c2a1d69bc258f0a513783aedaac3fcedb3e9c92b Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Wed, 12 Apr 2023 16:50:40 +0200 Subject: [PATCH 070/131] Delete Version.txt --- Winget-AutoUpdate/Winget-AutoUpdate/Version.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Winget-AutoUpdate/Winget-AutoUpdate/Version.txt diff --git a/Winget-AutoUpdate/Winget-AutoUpdate/Version.txt b/Winget-AutoUpdate/Winget-AutoUpdate/Version.txt deleted file mode 100644 index 250f359..0000000 --- a/Winget-AutoUpdate/Winget-AutoUpdate/Version.txt +++ /dev/null @@ -1 +0,0 @@ -1.17.4 \ No newline at end of file From 618797a114ae2bc0ae29bdf28c239de3abc38bbf Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Wed, 12 Apr 2023 16:51:47 +0200 Subject: [PATCH 071/131] Update AutoCreatePreVersion.yml --- .github/workflows/AutoCreatePreVersion.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/AutoCreatePreVersion.yml b/.github/workflows/AutoCreatePreVersion.yml index 8d9d2fe..208fe3c 100644 --- a/.github/workflows/AutoCreatePreVersion.yml +++ b/.github/workflows/AutoCreatePreVersion.yml @@ -28,7 +28,7 @@ jobs: - name: Overwrite Version.txt file uses: "DamianReeves/write-file-action@master" with: - path: Winget-AutoUpdate/Winget-AutoUpdate/Version.txt + path: Winget-AutoUpdate/Version.txt write-mode: overwrite contents: ${{ steps.versioning.outputs.version }} @@ -55,4 +55,4 @@ jobs: prerelease: true title: "v${{ steps.versioning.outputs.version }}" files: | - WAU.zip \ No newline at end of file + WAU.zip From 58a1278f02b7f71b387d5dd6d6723b65f90c2c0c Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Fri, 14 Apr 2023 18:44:22 +0200 Subject: [PATCH 072/131] Auto pre-release review --- .github/workflows/AutoCreatePreVersion.yml | 84 +++++++++++++++++----- 1 file changed, 67 insertions(+), 17 deletions(-) diff --git a/.github/workflows/AutoCreatePreVersion.yml b/.github/workflows/AutoCreatePreVersion.yml index 208fe3c..6071168 100644 --- a/.github/workflows/AutoCreatePreVersion.yml +++ b/.github/workflows/AutoCreatePreVersion.yml @@ -10,35 +10,85 @@ permissions: contents: write jobs: + get_date: + name: Get date for release version + runs-on: ubuntu-latest + outputs: + today: ${{ steps.get_today.outputs.NOW }} + steps: + - name: Set current date as env variable + id: get_today + run: echo "NOW=$(date +'%y%m%d')" >> $GITHUB_OUTPUT + - name: Echo current date + run: echo ${{ steps.get_today.outputs.NOW }} + + check_merged: + name: Check if latest merged commit is less than 24h + runs-on: ubuntu-latest + outputs: + should_run: ${{ steps.should_run.outputs.SHOULD_RUN }} + merged_sha: ${{ steps.merged_sha.outputs.MERGED_SHA }} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Get latest merged SHA if less than a day + id: merged_sha + run: echo "MERGED_SHA=$(git log -n 1 --merges --after="24 hours" --pretty=format:"%H")" >> $GITHUB_OUTPUT + - name: Check latest merged SHA if less than a day + id: should_run + run: | + echo ${{ steps.merged_sha.outputs.MERGED_SHA }} + if [ ${{ steps.merged_sha.outputs.MERGED_SHA }} != "" ]; then + echo "Latest Merged SHA: ${{ steps.merged_sha.outputs.MERGED_SHA }}" + echo "SHOULD_RUN=true" >> $GITHUB_OUTPUT + else + echo "No merged on last 24h" + echo "SHOULD_RUN=false" >> $GITHUB_OUTPUT + fi build: name: Create Release Asset + needs: [get_date, check_merged] + if: ${{ needs.check_merged.outputs.should_run == 'true' }} runs-on: ubuntu-latest steps: + - name: Echo env + run: | + echo "merged_sha: ${{ needs.check_merged.outputs.merged_sha }}" + echo "should_run: ${{ needs.check_merged.outputs.should_run }}" + echo "today: ${{ needs.get_date.outputs.today }}" + - name: Checkout code uses: actions/checkout@v3 with: lfs: 'true' - - - name: Auto Increment Semver Action - uses: MCKanpolat/auto-semver-action@v1 - id: versioning - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - + + - name: Get Current Latest Tag + uses: actions-ecosystem/action-get-latest-tag@v1 + id: previoustag + + - name: Format New Tag + id: new_tag + run: | + if [[ ${{ steps.previoustag.outputs.tag }} =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then + echo newtag=${BASH_REMATCH[0]} >> $GITHUB_OUTPUT + else + echo "Something is wrong with the version" + fi - name: Overwrite Version.txt file uses: "DamianReeves/write-file-action@master" with: path: Winget-AutoUpdate/Version.txt write-mode: overwrite - contents: ${{ steps.versioning.outputs.version }} + contents: "${{ steps.new_tag.outputs.newtag }}.${{ needs.get_date.outputs.today }}" - name: Commit & Push - uses: Andro999b/push@v1.3 + uses: actions-js/push@v1.4 with: github_token: ${{ secrets.GITHUB_TOKEN }} branch: main force: true - message: 'Changed version to ${{ steps.versioning.outputs.version }}' + message: 'Changed version to ${{ steps.new_tag.outputs.newtag }}.${{ needs.get_date.outputs.today }}' - name: Build project run: | @@ -47,12 +97,12 @@ jobs: zip -r WAU excluded_apps.txt zip -r WAU install.bat zip -r WAU uninstall.bat - - - uses: "marvinpinto/action-automatic-releases@latest" + + - name: Create release + uses: "ncipollo/release-action@v1" with: - repo_token: "${{ secrets.GITHUB_TOKEN }}" - automatic_release_tag: "v${{ steps.versioning.outputs.version }}" + tag: "v${{ steps.new_tag.outputs.newtag }}.${{ needs.get_date.outputs.today }}" prerelease: true - title: "v${{ steps.versioning.outputs.version }}" - files: | - WAU.zip + generateReleaseNotes: true + name: "v${{ steps.new_tag.outputs.newtag }}-${{ needs.get_date.outputs.today }} [Nightly Build]" + artifacts: "WAU.zip" From 68fb6a5a902b291469f0f627877ecf3b0b0db1ca Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Fri, 14 Apr 2023 19:08:09 +0200 Subject: [PATCH 073/131] Update cron --- .github/workflows/AutoCreatePreVersion.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/AutoCreatePreVersion.yml b/.github/workflows/AutoCreatePreVersion.yml index 6071168..9cabaa4 100644 --- a/.github/workflows/AutoCreatePreVersion.yml +++ b/.github/workflows/AutoCreatePreVersion.yml @@ -1,10 +1,8 @@ name: Auto Create Pre-Release Version on: - workflow_dispatch: - pull_request: - types: - - closed + schedule: + - cron: '0 0 * * *' permissions: contents: write From 7ea24b5cf08974dc38649865e81de79b8589fac4 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 15 Apr 2023 01:22:25 +0000 Subject: [PATCH 074/131] Changed version to 1.17.3.230415 --- Winget-AutoUpdate/Version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Winget-AutoUpdate/Version.txt b/Winget-AutoUpdate/Version.txt index 021c75e..29bff28 100644 --- a/Winget-AutoUpdate/Version.txt +++ b/Winget-AutoUpdate/Version.txt @@ -1 +1 @@ -1.17.3 \ No newline at end of file +1.17.3.230415 \ No newline at end of file From d15a61a5b8ceb3910805fbdded8e2ec0172f25fd Mon Sep 17 00:00:00 2001 From: Fabian Seitz Date: Mon, 17 Apr 2023 09:19:19 +0200 Subject: [PATCH 075/131] run megalinter only on PRs --- .github/workflows/mega-linter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mega-linter.yml b/.github/workflows/mega-linter.yml index 84304b1..3750b34 100644 --- a/.github/workflows/mega-linter.yml +++ b/.github/workflows/mega-linter.yml @@ -5,7 +5,7 @@ name: MegaLinter on: # Trigger mega-linter at every push. Action will also be visible from Pull Requests to main - push: # Comment this line to trigger action only on pull-requests (not recommended if you don't pay for GH Actions) + #push: # Comment this line to trigger action only on pull-requests (not recommended if you don't pay for GH Actions) pull_request: branches: [master, main] From b13ab4f493817ccc2688172da9f24c758f8a615a Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Tue, 18 Apr 2023 01:00:26 +0200 Subject: [PATCH 076/131] Review --- .github/workflows/AutoCreatePreVersion.yml | 106 ------------------ .../workflows/WAU-AutoCreatePreVersion.yml | 103 +++++++++++++++++ .github/workflows/WAU-CreateNewVersion.yml | 68 +++++++++++ 3 files changed, 171 insertions(+), 106 deletions(-) delete mode 100644 .github/workflows/AutoCreatePreVersion.yml create mode 100644 .github/workflows/WAU-AutoCreatePreVersion.yml create mode 100644 .github/workflows/WAU-CreateNewVersion.yml diff --git a/.github/workflows/AutoCreatePreVersion.yml b/.github/workflows/AutoCreatePreVersion.yml deleted file mode 100644 index 9cabaa4..0000000 --- a/.github/workflows/AutoCreatePreVersion.yml +++ /dev/null @@ -1,106 +0,0 @@ -name: Auto Create Pre-Release Version - -on: - schedule: - - cron: '0 0 * * *' - -permissions: - contents: write - -jobs: - get_date: - name: Get date for release version - runs-on: ubuntu-latest - outputs: - today: ${{ steps.get_today.outputs.NOW }} - steps: - - name: Set current date as env variable - id: get_today - run: echo "NOW=$(date +'%y%m%d')" >> $GITHUB_OUTPUT - - name: Echo current date - run: echo ${{ steps.get_today.outputs.NOW }} - - check_merged: - name: Check if latest merged commit is less than 24h - runs-on: ubuntu-latest - outputs: - should_run: ${{ steps.should_run.outputs.SHOULD_RUN }} - merged_sha: ${{ steps.merged_sha.outputs.MERGED_SHA }} - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Get latest merged SHA if less than a day - id: merged_sha - run: echo "MERGED_SHA=$(git log -n 1 --merges --after="24 hours" --pretty=format:"%H")" >> $GITHUB_OUTPUT - - name: Check latest merged SHA if less than a day - id: should_run - run: | - echo ${{ steps.merged_sha.outputs.MERGED_SHA }} - if [ ${{ steps.merged_sha.outputs.MERGED_SHA }} != "" ]; then - echo "Latest Merged SHA: ${{ steps.merged_sha.outputs.MERGED_SHA }}" - echo "SHOULD_RUN=true" >> $GITHUB_OUTPUT - else - echo "No merged on last 24h" - echo "SHOULD_RUN=false" >> $GITHUB_OUTPUT - fi - build: - name: Create Release Asset - needs: [get_date, check_merged] - if: ${{ needs.check_merged.outputs.should_run == 'true' }} - runs-on: ubuntu-latest - steps: - - name: Echo env - run: | - echo "merged_sha: ${{ needs.check_merged.outputs.merged_sha }}" - echo "should_run: ${{ needs.check_merged.outputs.should_run }}" - echo "today: ${{ needs.get_date.outputs.today }}" - - - name: Checkout code - uses: actions/checkout@v3 - with: - lfs: 'true' - - - name: Get Current Latest Tag - uses: actions-ecosystem/action-get-latest-tag@v1 - id: previoustag - - - name: Format New Tag - id: new_tag - run: | - if [[ ${{ steps.previoustag.outputs.tag }} =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then - echo newtag=${BASH_REMATCH[0]} >> $GITHUB_OUTPUT - else - echo "Something is wrong with the version" - fi - - name: Overwrite Version.txt file - uses: "DamianReeves/write-file-action@master" - with: - path: Winget-AutoUpdate/Version.txt - write-mode: overwrite - contents: "${{ steps.new_tag.outputs.newtag }}.${{ needs.get_date.outputs.today }}" - - - name: Commit & Push - uses: actions-js/push@v1.4 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - branch: main - force: true - message: 'Changed version to ${{ steps.new_tag.outputs.newtag }}.${{ needs.get_date.outputs.today }}' - - - name: Build project - run: | - zip -r WAU Winget-AutoUpdate/* - zip -r WAU Winget-AutoUpdate-Install.ps1 - zip -r WAU excluded_apps.txt - zip -r WAU install.bat - zip -r WAU uninstall.bat - - - name: Create release - uses: "ncipollo/release-action@v1" - with: - tag: "v${{ steps.new_tag.outputs.newtag }}.${{ needs.get_date.outputs.today }}" - prerelease: true - generateReleaseNotes: true - name: "v${{ steps.new_tag.outputs.newtag }}-${{ needs.get_date.outputs.today }} [Nightly Build]" - artifacts: "WAU.zip" diff --git a/.github/workflows/WAU-AutoCreatePreVersion.yml b/.github/workflows/WAU-AutoCreatePreVersion.yml new file mode 100644 index 0000000..ba9b1f6 --- /dev/null +++ b/.github/workflows/WAU-AutoCreatePreVersion.yml @@ -0,0 +1,103 @@ +name: Auto Create Pre-Release Version + +on: + schedule: + - cron: '0 2 * * *' + +permissions: + contents: write + +jobs: + check_merged: + name: Compare latest merge and tag + runs-on: ubuntu-latest + outputs: + should_run: ${{ steps.should_run.outputs.SHOULD_RUN }} + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Check if latest merged is older than latest tag + id: should_run + run: | + echo "Latest tag:" + git log --tags --pretty="%ci - %h - %s %d" -n 1 + LATEST_TAG_DATE=$(git log --tags -n 1 --pretty="%ct") + echo $LATEST_TAG_DATE + + echo "Latest merge:" + git log --merges --pretty="%ci - %h - %s %d" -n 1 + LATEST_MERGE_DATE=$(git log --merges -n 1 --pretty="%ct") + echo $LATEST_MERGE_DATE + + if [[ $LATEST_MERGE_DATE -gt $LATEST_TAG_DATE ]]; then + echo "Latest tag is older than latest merge. Nightly will be created." + echo "SHOULD_RUN=true" >> $GITHUB_OUTPUT + else + echo "Latest merge is not older than latest tag. No new release needed." + echo "SHOULD_RUN=false" >> $GITHUB_OUTPUT + fi + + build: + name: Create Release Asset + needs: [check_merged] + if: ${{ needs.check_merged.outputs.should_run == 'true' }} + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + lfs: 'true' + fetch-depth: 0 + + - name: Auto Increment Semver Action + uses: MCKanpolat/auto-semver-action@1.0.9 + id: versioning + with: + releaseType: prerelease + incrementPerCommit: false + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Next Release Number + id: WAU_version + run: | + echo "Next Release version: ${{ steps.versioning.outputs.version }}" + echo "PowerShell format version: ${{ steps.versioning.outputs.version }}" | tr '-' '.' + echo PSVersion=$(echo '${{ steps.versioning.outputs.version }}' | tr '-' '.') >> $GITHUB_OUTPUT + + - name: Overwrite Version.txt file + uses: DamianReeves/write-file-action@v1.2 + with: + path: Winget-AutoUpdate/Version.txt + write-mode: overwrite + contents: ${{ steps.WAU_version.outputs.PSVersion }} + + - name: Commit & Push + uses: actions-js/push@v1.4 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: main + force: true + message: 'Changed version to ${{ steps.versioning.outputs.version }}' + + - name: Build project + run: | + zip -r WAU Winget-AutoUpdate/* + zip -r WAU Winget-AutoUpdate-Install.ps1 + zip -r WAU excluded_apps.txt + zip -r WAU install.bat + zip -r WAU uninstall.bat + + - name: Create release + uses: "ncipollo/release-action@v1" + id: release + with: + tag: "v${{ steps.versioning.outputs.version }}" + prerelease: true + generateReleaseNotes: true + name: "v${{ steps.versioning.outputs.version }} [Nightly Build]" + artifacts: "WAU.zip" + + - name: URL to release + run: echo "Release -> ${{ steps.release.outputs.html_url }}" \ No newline at end of file diff --git a/.github/workflows/WAU-CreateNewVersion.yml b/.github/workflows/WAU-CreateNewVersion.yml new file mode 100644 index 0000000..a61898d --- /dev/null +++ b/.github/workflows/WAU-CreateNewVersion.yml @@ -0,0 +1,68 @@ +name: Create New Version + +on: + workflow_dispatch: + inputs: + version: + type: choice + description: Select next release type + options: + - Patch + - Minor + - Major + pre-release: + type: boolean + description: Set as Pre-release version + +permissions: + contents: write + +jobs: + build: + name: Create Release Asset + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + lfs: 'true' + + - name: Auto Increment Semver Action + uses: MCKanpolat/auto-semver-action@1.0.9 + id: versioning + with: + releaseType: ${{ github.event.inputs.version }} + incrementPerCommit: false + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Overwrite Version.txt file + uses: DamianReeves/write-file-action@v1.2 + with: + path: Winget-AutoUpdate/Version.txt + write-mode: overwrite + contents: "${{ steps.versioning.outputs.version }}" + + - name: Commit & Push + uses: actions-js/push@v1.4 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: main + force: true + message: 'Changed version to ${{ steps.versioning.outputs.version }}' + + - name: Build project + run: | + zip -r WAU Winget-AutoUpdate/* + zip -r WAU Winget-AutoUpdate-Install.ps1 + zip -r WAU excluded_apps.txt + zip -r WAU install.bat + zip -r WAU uninstall.bat + + - name: Create release + uses: "ncipollo/release-action@v1" + with: + tag: "v${{ steps.versioning.outputs.version }}" + prerelease: ${{ github.event.inputs.pre-release }} + generateReleaseNotes: true + name: "v${{ steps.versioning.outputs.version }}" + artifacts: "WAU.zip" \ No newline at end of file From 32955b141848c1589442c4525d4b44b735820c2d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 18 Apr 2023 02:27:55 +0000 Subject: [PATCH 077/131] Changed version to 1.17.4-0 --- Winget-AutoUpdate/Version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Winget-AutoUpdate/Version.txt b/Winget-AutoUpdate/Version.txt index 29bff28..8391ba2 100644 --- a/Winget-AutoUpdate/Version.txt +++ b/Winget-AutoUpdate/Version.txt @@ -1 +1 @@ -1.17.3.230415 \ No newline at end of file +1.17.4.0 \ No newline at end of file From 4814bb5a9edff888590d3afe8977a0b113641e9a Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Tue, 18 Apr 2023 11:44:59 +0200 Subject: [PATCH 078/131] Changes the way WAU is packaged and updated regarding new release processes --- Winget-AutoUpdate/functions/Get-WAUAvailableVersion.ps1 | 3 ++- Winget-AutoUpdate/functions/Update-WAU.ps1 | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Winget-AutoUpdate/functions/Get-WAUAvailableVersion.ps1 b/Winget-AutoUpdate/functions/Get-WAUAvailableVersion.ps1 index 0d3e535..2a2e873 100644 --- a/Winget-AutoUpdate/functions/Get-WAUAvailableVersion.ps1 +++ b/Winget-AutoUpdate/functions/Get-WAUAvailableVersion.ps1 @@ -19,6 +19,7 @@ function Get-WAUAvailableVersion { } - return ((Invoke-WebRequest $WAUurl -UseBasicParsing | ConvertFrom-Json)[0].tag_name).Replace("v", "") + #Return version to windows format (1.0.0 or 1.0.0.0 for nightlies) + return (((Invoke-WebRequest $WAUurl -UseBasicParsing | ConvertFrom-Json)[0].tag_name).Replace("v", "")).Replace("-", ".") } diff --git a/Winget-AutoUpdate/functions/Update-WAU.ps1 b/Winget-AutoUpdate/functions/Update-WAU.ps1 index 0b2f22f..6ca47e7 100644 --- a/Winget-AutoUpdate/functions/Update-WAU.ps1 +++ b/Winget-AutoUpdate/functions/Update-WAU.ps1 @@ -20,7 +20,7 @@ function Update-WAU { #Download the zip Write-ToLog "Downloading the GitHub Repository version $WAUAvailableVersion" "Cyan" - Invoke-RestMethod -Uri "https://github.com/Romanitho/Winget-AutoUpdate/archive/refs/tags/v$($WAUAvailableVersion).zip/" -OutFile $ZipFile + Invoke-RestMethod -Uri "https://github.com/Romanitho/Winget-AutoUpdate/releases/download/v$($WAUAvailableVersion)/WAU.zip" -OutFile $ZipFile #Extract Zip File Write-ToLog "Unzipping the WAU GitHub Repository" "Cyan" @@ -30,7 +30,7 @@ function Update-WAU { #Update scritps Write-ToLog "Updating WAU" "Yellow" - $TempPath = (Resolve-Path "$location\*\Winget-AutoUpdate\")[0].Path + $TempPath = (Resolve-Path "$location\Winget-AutoUpdate\")[0].Path if ($TempPath) { Copy-Item -Path "$TempPath\*" -Destination "$WorkingDir\" -Exclude "icons" -Recurse -Force } From 4f6d31641945d2f593499747d90fae3bd2842c67 Mon Sep 17 00:00:00 2001 From: Fabian Seitz Date: Tue, 18 Apr 2023 14:41:35 +0200 Subject: [PATCH 079/131] Improve Github Workflows --- .github/workflows/CloseInactiveIssues.yml | 1 + .github/workflows/WAU-AutoCreatePreVersion.yml | 1 + .github/workflows/WAU-CreateNewVersion.yml | 7 ++++--- .github/workflows/mega-linter.yml | 2 +- .github/workflows/powershell-tests.yaml | 1 + 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/CloseInactiveIssues.yml b/.github/workflows/CloseInactiveIssues.yml index d86e255..daad263 100644 --- a/.github/workflows/CloseInactiveIssues.yml +++ b/.github/workflows/CloseInactiveIssues.yml @@ -1,3 +1,4 @@ +--- name: Close inactive issues on: schedule: diff --git a/.github/workflows/WAU-AutoCreatePreVersion.yml b/.github/workflows/WAU-AutoCreatePreVersion.yml index ba9b1f6..f40d956 100644 --- a/.github/workflows/WAU-AutoCreatePreVersion.yml +++ b/.github/workflows/WAU-AutoCreatePreVersion.yml @@ -1,3 +1,4 @@ +--- name: Auto Create Pre-Release Version on: diff --git a/.github/workflows/WAU-CreateNewVersion.yml b/.github/workflows/WAU-CreateNewVersion.yml index a61898d..b36522b 100644 --- a/.github/workflows/WAU-CreateNewVersion.yml +++ b/.github/workflows/WAU-CreateNewVersion.yml @@ -1,3 +1,4 @@ +--- name: Create New Version on: @@ -7,9 +8,9 @@ on: type: choice description: Select next release type options: - - Patch - - Minor - - Major + - Patch + - Minor + - Major pre-release: type: boolean description: Set as Pre-release version diff --git a/.github/workflows/mega-linter.yml b/.github/workflows/mega-linter.yml index 3750b34..3711c55 100644 --- a/.github/workflows/mega-linter.yml +++ b/.github/workflows/mega-linter.yml @@ -50,7 +50,7 @@ jobs: SPELL_CSPELL_CONFIG_FILE: .github/cspell.json POWERSHELL_POWERSHELL_CONFIG_FILE: .github/.powershell-psscriptanalyzer.psd1 DISABLE_ERRORS_LINTERS: REPOSITORY_DEVSKIM,REPOSITORY_GIT_DIFF,SPELL_CSPELL,SPELL_PROSELINT,COPYPASTE_JSCPD,MARKDOWN_MARKDOWN_LINK_CHECK - FILTER_REGEX_EXCLUDE: (.github/workflows/) + FILTER_REGEX_EXCLUDE: (workflows/) # Upload MegaLinter artifacts - name: Archive production artifacts diff --git a/.github/workflows/powershell-tests.yaml b/.github/workflows/powershell-tests.yaml index 8c6bef0..4933f7f 100644 --- a/.github/workflows/powershell-tests.yaml +++ b/.github/workflows/powershell-tests.yaml @@ -1,3 +1,4 @@ +--- name: WAU PS Test # yamllint disable-line rule:truthy From 720215d664d66c31ae526e58235247aca39466a1 Mon Sep 17 00:00:00 2001 From: Fabian Seitz Date: Tue, 18 Apr 2023 14:49:26 +0200 Subject: [PATCH 080/131] Improved Github Workflows --- .github/workflows/WAU-CreateNewVersion.yml | 2 ++ .github/workflows/powershell-tests.yaml | 8 ++------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/WAU-CreateNewVersion.yml b/.github/workflows/WAU-CreateNewVersion.yml index b36522b..e35623c 100644 --- a/.github/workflows/WAU-CreateNewVersion.yml +++ b/.github/workflows/WAU-CreateNewVersion.yml @@ -6,11 +6,13 @@ on: inputs: version: type: choice + default: 'Patch' description: Select next release type options: - Patch - Minor - Major + required: true pre-release: type: boolean description: Set as Pre-release version diff --git a/.github/workflows/powershell-tests.yaml b/.github/workflows/powershell-tests.yaml index 4933f7f..4936854 100644 --- a/.github/workflows/powershell-tests.yaml +++ b/.github/workflows/powershell-tests.yaml @@ -1,14 +1,10 @@ --- -name: WAU PS Test +name: WAU Powershell Test Runs # yamllint disable-line rule:truthy on: - push: pull_request: - types: - - opened - - reopened - - synchronize + branches: [master, main] workflow_dispatch: permissions: From 9cd4dd23c1d5414cf1fe892bb7b73de97869c9ff Mon Sep 17 00:00:00 2001 From: Fabian Seitz Date: Tue, 18 Apr 2023 14:57:03 +0200 Subject: [PATCH 081/131] remove REPOSITORY_CHECKOV from megalinter check --- .github/workflows/mega-linter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mega-linter.yml b/.github/workflows/mega-linter.yml index 3711c55..d3ae61f 100644 --- a/.github/workflows/mega-linter.yml +++ b/.github/workflows/mega-linter.yml @@ -49,7 +49,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SPELL_CSPELL_CONFIG_FILE: .github/cspell.json POWERSHELL_POWERSHELL_CONFIG_FILE: .github/.powershell-psscriptanalyzer.psd1 - DISABLE_ERRORS_LINTERS: REPOSITORY_DEVSKIM,REPOSITORY_GIT_DIFF,SPELL_CSPELL,SPELL_PROSELINT,COPYPASTE_JSCPD,MARKDOWN_MARKDOWN_LINK_CHECK + DISABLE_ERRORS_LINTERS: REPOSITORY_DEVSKIM,REPOSITORY_CHECKOV,REPOSITORY_GIT_DIFF,SPELL_CSPELL,SPELL_PROSELINT,COPYPASTE_JSCPD,MARKDOWN_MARKDOWN_LINK_CHECK FILTER_REGEX_EXCLUDE: (workflows/) # Upload MegaLinter artifacts From 3081645319793ffc43161417dc725f9c1979569b Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Wed, 19 Apr 2023 22:43:13 +0200 Subject: [PATCH 082/131] fixed new version implementation for pre-releases --- Winget-AutoUpdate/Winget-Upgrade.ps1 | 4 ++-- Winget-AutoUpdate/functions/Get-WAUAvailableVersion.ps1 | 4 ++-- Winget-AutoUpdate/functions/Update-WAU.ps1 | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Winget-AutoUpdate/Winget-Upgrade.ps1 b/Winget-AutoUpdate/Winget-Upgrade.ps1 index d8b015b..54d226b 100644 --- a/Winget-AutoUpdate/Winget-Upgrade.ps1 +++ b/Winget-AutoUpdate/Winget-Upgrade.ps1 @@ -92,9 +92,9 @@ if (Test-Network) { else { Write-ToLog "WAU AutoUpdate is Enabled." "Green" #Get Available Version - $WAUAvailableVersion = Get-WAUAvailableVersion + $Script:WAUAvailableVersion = Get-WAUAvailableVersion #Compare - if ([version]$WAUAvailableVersion -gt [version]$WAUCurrentVersion) { + if ([version]$WAUAvailableVersion.Replace("-", ".") -ne [version]$WAUCurrentVersion) { #If new version is available, update it Write-ToLog "WAU Available version: $WAUAvailableVersion" "Yellow" Update-WAU diff --git a/Winget-AutoUpdate/functions/Get-WAUAvailableVersion.ps1 b/Winget-AutoUpdate/functions/Get-WAUAvailableVersion.ps1 index 2a2e873..c2241ab 100644 --- a/Winget-AutoUpdate/functions/Get-WAUAvailableVersion.ps1 +++ b/Winget-AutoUpdate/functions/Get-WAUAvailableVersion.ps1 @@ -19,7 +19,7 @@ function Get-WAUAvailableVersion { } - #Return version to windows format (1.0.0 or 1.0.0.0 for nightlies) - return (((Invoke-WebRequest $WAUurl -UseBasicParsing | ConvertFrom-Json)[0].tag_name).Replace("v", "")).Replace("-", ".") + #Return version + return ((Invoke-WebRequest $WAUurl -UseBasicParsing | ConvertFrom-Json)[0].tag_name).Replace("v", "") } diff --git a/Winget-AutoUpdate/functions/Update-WAU.ps1 b/Winget-AutoUpdate/functions/Update-WAU.ps1 index 6ca47e7..36d3e21 100644 --- a/Winget-AutoUpdate/functions/Update-WAU.ps1 +++ b/Winget-AutoUpdate/functions/Update-WAU.ps1 @@ -41,9 +41,9 @@ function Update-WAU { Remove-Item -Path $location -Recurse -Force -ErrorAction SilentlyContinue #Set new version to registry - $WAUConfig | New-ItemProperty -Name DisplayVersion -Value $WAUAvailableVersion -Force - $WAUConfig | New-ItemProperty -Name VersionMajor -Value ([version]$WAUAvailableVersion).Major -Force - $WAUConfig | New-ItemProperty -Name VersionMinor -Value ([version]$WAUAvailableVersion).Minor -Force + $WAUConfig | New-ItemProperty -Name DisplayVersion -Value $($WAUAvailableVersion.Replace("-", ".")) -Force + $WAUConfig | New-ItemProperty -Name VersionMajor -Value ([version]$WAUAvailableVersion.Replace("-", ".")).Major -Force + $WAUConfig | New-ItemProperty -Name VersionMinor -Value ([version]$WAUAvailableVersion.Replace("-", ".")).Minor -Force #Set Post Update actions to 1 $WAUConfig | New-ItemProperty -Name WAU_PostUpdateActions -Value 1 -Force From 610c146c13154eb16e3c9ee715c96500f5fe8502 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Wed, 19 Apr 2023 22:57:46 +0200 Subject: [PATCH 083/131] Remove "Write-Log.ps1" as replaced by "Write-ToLog.ps1" --- Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 index e423df7..b20cfbe 100644 --- a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 +++ b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 @@ -193,7 +193,8 @@ function Invoke-PostUpdateActions { $FileNames = @( "$WorkingDir\functions\Get-WAUConfig.ps1", "$WorkingDir\functions\Get-WAUCurrentVersion.ps1", - "$WorkingDir\functions\Get-WAUUpdateStatus.ps1" + "$WorkingDir\functions\Get-WAUUpdateStatus.ps1", + "$WorkingDir\functions\Write-Log.ps1" ) foreach ($FileName in $FileNames) { if (Test-Path $FileName) { From d3f6dd5f7cebf039a41eda1585cce4a3f6e1cc89 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 20 Apr 2023 02:28:50 +0000 Subject: [PATCH 084/131] Changed version to 1.17.4-1 --- Winget-AutoUpdate/Version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Winget-AutoUpdate/Version.txt b/Winget-AutoUpdate/Version.txt index 8391ba2..b9492b8 100644 --- a/Winget-AutoUpdate/Version.txt +++ b/Winget-AutoUpdate/Version.txt @@ -1 +1 @@ -1.17.4.0 \ No newline at end of file +1.17.4.1 \ No newline at end of file From 7b6fb35c01bdd4a8b7f714229c0738512c094f10 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Thu, 20 Apr 2023 04:35:54 +0200 Subject: [PATCH 085/131] Midnight UTC --- .github/workflows/WAU-AutoCreatePreVersion.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/WAU-AutoCreatePreVersion.yml b/.github/workflows/WAU-AutoCreatePreVersion.yml index f40d956..e24bd01 100644 --- a/.github/workflows/WAU-AutoCreatePreVersion.yml +++ b/.github/workflows/WAU-AutoCreatePreVersion.yml @@ -3,7 +3,7 @@ name: Auto Create Pre-Release Version on: schedule: - - cron: '0 2 * * *' + - cron: '0 0 * * *' permissions: contents: write @@ -101,4 +101,4 @@ jobs: artifacts: "WAU.zip" - name: URL to release - run: echo "Release -> ${{ steps.release.outputs.html_url }}" \ No newline at end of file + run: echo "Release -> ${{ steps.release.outputs.html_url }}" From 44a392787c57af120b047c66afbdc4f030adc9cf Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Thu, 20 Apr 2023 22:20:17 +0200 Subject: [PATCH 086/131] Fixing a NULL if Mods not in AzureBlob --- Winget-AutoUpdate/Winget-Upgrade.ps1 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Winget-AutoUpdate/Winget-Upgrade.ps1 b/Winget-AutoUpdate/Winget-Upgrade.ps1 index 54d226b..2ed35a1 100644 --- a/Winget-AutoUpdate/Winget-Upgrade.ps1 +++ b/Winget-AutoUpdate/Winget-Upgrade.ps1 @@ -152,7 +152,12 @@ if (Test-Network) { if ($WAUConfig.WAU_ModsPath) { $ModsPathClean = $($WAUConfig.WAU_ModsPath.TrimEnd(" ", "\", "/")) Write-ToLog "WAU uses External Mods from: $ModsPathClean" - $NewMods, $DeletedMods = Test-ModsPath $ModsPathClean $WAUConfig.InstallLocation.TrimEnd(" ", "\") $WAUConfig.WAU_AzureBlobSASURL.TrimEnd(" ") + if ($WAUConfig.WAU_AzureBlobSASURL) { + $NewMods, $DeletedMods = Test-ModsPath $ModsPathClean $WAUConfig.InstallLocation.TrimEnd(" ", "\") $WAUConfig.WAU_AzureBlobSASURL.TrimEnd(" ") + } + else { + $NewMods, $DeletedMods = Test-ModsPath $ModsPathClean $WAUConfig.InstallLocation.TrimEnd(" ", "\") + } if ($ReachNoPath) { Write-ToLog "Couldn't reach/find/compare/copy from $ModsPathClean..." "Red" $Script:ReachNoPath = $False From 300335c0692d80e0ea1543f08922a3b1c6ccfb46 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 21 Apr 2023 00:31:26 +0000 Subject: [PATCH 087/131] Changed version to 1.17.4-2 --- Winget-AutoUpdate/Version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Winget-AutoUpdate/Version.txt b/Winget-AutoUpdate/Version.txt index b9492b8..fb7435a 100644 --- a/Winget-AutoUpdate/Version.txt +++ b/Winget-AutoUpdate/Version.txt @@ -1 +1 @@ -1.17.4.1 \ No newline at end of file +1.17.4.2 \ No newline at end of file From 69fdf4430b1cba5ea0c4c4d8a5728cc83e4c54b0 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Sat, 22 Apr 2023 05:43:00 +0200 Subject: [PATCH 088/131] Update WAU-AutoCreatePreVersion.yml --- .github/workflows/WAU-AutoCreatePreVersion.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/WAU-AutoCreatePreVersion.yml b/.github/workflows/WAU-AutoCreatePreVersion.yml index e24bd01..e90a140 100644 --- a/.github/workflows/WAU-AutoCreatePreVersion.yml +++ b/.github/workflows/WAU-AutoCreatePreVersion.yml @@ -1,5 +1,5 @@ --- -name: Auto Create Pre-Release Version +name: WAU - Auto Create Pre-Release Version on: schedule: From e3c64a860a54697962b9c052cb4b30ef520ee262 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Sat, 22 Apr 2023 05:43:31 +0200 Subject: [PATCH 089/131] Update WAU-CreateNewVersion.yml --- .github/workflows/WAU-CreateNewVersion.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/WAU-CreateNewVersion.yml b/.github/workflows/WAU-CreateNewVersion.yml index e35623c..656f66a 100644 --- a/.github/workflows/WAU-CreateNewVersion.yml +++ b/.github/workflows/WAU-CreateNewVersion.yml @@ -1,5 +1,5 @@ --- -name: Create New Version +name: WAU - Create New Version on: workflow_dispatch: @@ -68,4 +68,4 @@ jobs: prerelease: ${{ github.event.inputs.pre-release }} generateReleaseNotes: true name: "v${{ steps.versioning.outputs.version }}" - artifacts: "WAU.zip" \ No newline at end of file + artifacts: "WAU.zip" From 232fe77f8cf50910ca2af55b3a66363948339759 Mon Sep 17 00:00:00 2001 From: romanitho <96626929+Romanitho@users.noreply.github.com> Date: Sat, 22 Apr 2023 13:06:20 +0200 Subject: [PATCH 090/131] Version adjustments --- .github/workflows/WAU-AutoCreatePreVersion.yml | 6 +++--- .github/workflows/WAU-CreateNewVersion.yml | 6 +++--- Winget-AutoUpdate/Winget-Upgrade.ps1 | 2 +- Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 | 8 ++++---- Winget-AutoUpdate/functions/Update-WAU.ps1 | 8 ++++---- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/WAU-AutoCreatePreVersion.yml b/.github/workflows/WAU-AutoCreatePreVersion.yml index e90a140..b13e351 100644 --- a/.github/workflows/WAU-AutoCreatePreVersion.yml +++ b/.github/workflows/WAU-AutoCreatePreVersion.yml @@ -3,7 +3,7 @@ name: WAU - Auto Create Pre-Release Version on: schedule: - - cron: '0 0 * * *' + - cron: "0 0 * * *" permissions: contents: write @@ -49,7 +49,7 @@ jobs: - name: Checkout code uses: actions/checkout@v3 with: - lfs: 'true' + lfs: "true" fetch-depth: 0 - name: Auto Increment Semver Action @@ -80,7 +80,7 @@ jobs: github_token: ${{ secrets.GITHUB_TOKEN }} branch: main force: true - message: 'Changed version to ${{ steps.versioning.outputs.version }}' + message: "Changed version to ${{ steps.versioning.outputs.version }}" - name: Build project run: | diff --git a/.github/workflows/WAU-CreateNewVersion.yml b/.github/workflows/WAU-CreateNewVersion.yml index 656f66a..bf7dbd1 100644 --- a/.github/workflows/WAU-CreateNewVersion.yml +++ b/.github/workflows/WAU-CreateNewVersion.yml @@ -6,7 +6,7 @@ on: inputs: version: type: choice - default: 'Patch' + default: "Patch" description: Select next release type options: - Patch @@ -28,7 +28,7 @@ jobs: - name: Checkout code uses: actions/checkout@v3 with: - lfs: 'true' + lfs: "true" - name: Auto Increment Semver Action uses: MCKanpolat/auto-semver-action@1.0.9 @@ -51,7 +51,7 @@ jobs: github_token: ${{ secrets.GITHUB_TOKEN }} branch: main force: true - message: 'Changed version to ${{ steps.versioning.outputs.version }}' + message: "Changed version to ${{ steps.versioning.outputs.version }}" - name: Build project run: | diff --git a/Winget-AutoUpdate/Winget-Upgrade.ps1 b/Winget-AutoUpdate/Winget-Upgrade.ps1 index 2ed35a1..3b2e8e0 100644 --- a/Winget-AutoUpdate/Winget-Upgrade.ps1 +++ b/Winget-AutoUpdate/Winget-Upgrade.ps1 @@ -94,7 +94,7 @@ if (Test-Network) { #Get Available Version $Script:WAUAvailableVersion = Get-WAUAvailableVersion #Compare - if ([version]$WAUAvailableVersion.Replace("-", ".") -ne [version]$WAUCurrentVersion) { + if ([version]$WAUAvailableVersion.Replace("-", ".") -ne [version]$WAUCurrentVersion.Replace("-", ".")) { #If new version is available, update it Write-ToLog "WAU Available version: $WAUAvailableVersion" "Yellow" Update-WAU diff --git a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 index b20cfbe..e952927 100644 --- a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 +++ b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 @@ -45,9 +45,8 @@ function Invoke-PostUpdateActions { Write-ToLog "-> Prerequisites checked. OK" "green" } - Write-ToLog "-> Checking if Winget is installed/up to date" "yellow" - #Check Package Install + Write-ToLog "-> Checking if Winget is installed/up to date" "yellow" $TestWinGet = Get-AppxProvisionedPackage -Online | Where-Object { $_.DisplayName -eq "Microsoft.DesktopAppInstaller" } #Current: v1.4.10173 = 1.19.10173.0 = 2023.118.406.0 @@ -189,12 +188,13 @@ function Invoke-PostUpdateActions { Write-ToLog "-> $WAUConfigPath converted." "green" } - #Remove old functions + #Remove old functions / files $FileNames = @( "$WorkingDir\functions\Get-WAUConfig.ps1", "$WorkingDir\functions\Get-WAUCurrentVersion.ps1", "$WorkingDir\functions\Get-WAUUpdateStatus.ps1", - "$WorkingDir\functions\Write-Log.ps1" + "$WorkingDir\functions\Write-Log.ps1", + "$WorkingDir\Version.txt" ) foreach ($FileName in $FileNames) { if (Test-Path $FileName) { diff --git a/Winget-AutoUpdate/functions/Update-WAU.ps1 b/Winget-AutoUpdate/functions/Update-WAU.ps1 index 36d3e21..123deb9 100644 --- a/Winget-AutoUpdate/functions/Update-WAU.ps1 +++ b/Winget-AutoUpdate/functions/Update-WAU.ps1 @@ -23,25 +23,25 @@ function Update-WAU { Invoke-RestMethod -Uri "https://github.com/Romanitho/Winget-AutoUpdate/releases/download/v$($WAUAvailableVersion)/WAU.zip" -OutFile $ZipFile #Extract Zip File - Write-ToLog "Unzipping the WAU GitHub Repository" "Cyan" + Write-ToLog "Unzipping the WAU Update package" "Cyan" $location = "$WorkingDir\WAU_update" Expand-Archive -Path $ZipFile -DestinationPath $location -Force Get-ChildItem -Path $location -Recurse | Unblock-File #Update scritps - Write-ToLog "Updating WAU" "Yellow" + Write-ToLog "Updating WAU..." "Yellow" $TempPath = (Resolve-Path "$location\Winget-AutoUpdate\")[0].Path if ($TempPath) { Copy-Item -Path "$TempPath\*" -Destination "$WorkingDir\" -Exclude "icons" -Recurse -Force } #Remove update zip file and update temp folder - Write-ToLog "Done. Cleaning temp files" "Cyan" + Write-ToLog "Done. Cleaning temp files..." "Cyan" Remove-Item -Path $ZipFile -Force -ErrorAction SilentlyContinue Remove-Item -Path $location -Recurse -Force -ErrorAction SilentlyContinue #Set new version to registry - $WAUConfig | New-ItemProperty -Name DisplayVersion -Value $($WAUAvailableVersion.Replace("-", ".")) -Force + $WAUConfig | New-ItemProperty -Name DisplayVersion -Value $WAUAvailableVersion -Force $WAUConfig | New-ItemProperty -Name VersionMajor -Value ([version]$WAUAvailableVersion.Replace("-", ".")).Major -Force $WAUConfig | New-ItemProperty -Name VersionMinor -Value ([version]$WAUAvailableVersion.Replace("-", ".")).Minor -Force From ae5f946fcd109cc744d125f6bc5cd6a76c0ad62c Mon Sep 17 00:00:00 2001 From: romanitho <96626929+Romanitho@users.noreply.github.com> Date: Sat, 22 Apr 2023 14:00:07 +0200 Subject: [PATCH 091/131] Remove useless regkeys --- .github/workflows/WAU-AutoCreatePreVersion.yml | 4 +--- Winget-AutoUpdate-Install.ps1 | 2 -- .../functions/Invoke-PostUpdateActions.ps1 | 15 ++++++++++++--- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/WAU-AutoCreatePreVersion.yml b/.github/workflows/WAU-AutoCreatePreVersion.yml index b13e351..953e187 100644 --- a/.github/workflows/WAU-AutoCreatePreVersion.yml +++ b/.github/workflows/WAU-AutoCreatePreVersion.yml @@ -64,15 +64,13 @@ jobs: id: WAU_version run: | echo "Next Release version: ${{ steps.versioning.outputs.version }}" - echo "PowerShell format version: ${{ steps.versioning.outputs.version }}" | tr '-' '.' - echo PSVersion=$(echo '${{ steps.versioning.outputs.version }}' | tr '-' '.') >> $GITHUB_OUTPUT - name: Overwrite Version.txt file uses: DamianReeves/write-file-action@v1.2 with: path: Winget-AutoUpdate/Version.txt write-mode: overwrite - contents: ${{ steps.WAU_version.outputs.PSVersion }} + contents: ${{ steps.versioning.outputs.version }} - name: Commit & Push uses: actions-js/push@v1.4 diff --git a/Winget-AutoUpdate-Install.ps1 b/Winget-AutoUpdate-Install.ps1 index fe37eca..d72ce5a 100644 --- a/Winget-AutoUpdate-Install.ps1 +++ b/Winget-AutoUpdate-Install.ps1 @@ -340,8 +340,6 @@ function Install-WingetAutoUpdate { New-ItemProperty $regPath -Name QuietUninstallString -Value "powershell.exe -noprofile -executionpolicy bypass -file `"$WingetUpdatePath\WAU-Uninstall.ps1`"" -Force | Out-Null New-ItemProperty $regPath -Name NoModify -Value 1 -Force | Out-Null New-ItemProperty $regPath -Name NoRepair -Value 1 -Force | Out-Null - New-ItemProperty $regPath -Name VersionMajor -Value ([version]$WAUVersion).Major -Force | Out-Null - New-ItemProperty $regPath -Name VersionMinor -Value ([version]$WAUVersion).Minor -Force | Out-Null New-ItemProperty $regPath -Name Publisher -Value "Romanitho" -Force | Out-Null New-ItemProperty $regPath -Name URLInfoAbout -Value "https://github.com/Romanitho/Winget-AutoUpdate" -Force | Out-Null New-ItemProperty $regPath -Name WAU_NotificationLevel -Value $NotificationLevel -Force | Out-Null diff --git a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 index e952927..ffd98bb 100644 --- a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 +++ b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 @@ -157,13 +157,11 @@ function Invoke-PostUpdateActions { Write-ToLog "-> Error: The mods directory couldn't be verified as secured!" "red" } - #Convert about.xml if exists (previous WAU versions) to reg + #Convert about.xml if exists (old WAU versions) to reg $WAUAboutPath = "$WorkingDir\config\about.xml" if (test-path $WAUAboutPath) { [xml]$About = Get-Content $WAUAboutPath -Encoding UTF8 -ErrorAction SilentlyContinue New-ItemProperty $regPath -Name DisplayVersion -Value $About.app.version -Force - New-ItemProperty $regPath -Name VersionMajor -Value ([version]$About.app.version).Major -Force - New-ItemProperty $regPath -Name VersionMinor -Value ([version]$About.app.version).Minor -Force #Remove file once converted Remove-Item $WAUAboutPath -Force -Confirm:$false @@ -205,6 +203,17 @@ function Invoke-PostUpdateActions { } } + #Remove old registry key + $RegistryKeys = @( + "VersionMajor", + "VersionMinor" + ) + foreach ($RegistryKey in $RegistryKeys) { + if (Get-ItemProperty -Path $regPath -Name $RegistryKey -ErrorAction SilentlyContinue) { + Remove-ItemProperty -Path $regPath -Name $RegistryKey + } + } + #Reset WAU_UpdatePostActions Value $WAUConfig | New-ItemProperty -Name WAU_PostUpdateActions -Value 0 -Force From 1f1c6f22cd3bc884b6bd5997f843e682ae813e96 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 22 Apr 2023 13:59:20 +0000 Subject: [PATCH 092/131] Changed version to 1.17.4 --- Winget-AutoUpdate/Version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Winget-AutoUpdate/Version.txt b/Winget-AutoUpdate/Version.txt index fb7435a..250f359 100644 --- a/Winget-AutoUpdate/Version.txt +++ b/Winget-AutoUpdate/Version.txt @@ -1 +1 @@ -1.17.4.2 \ No newline at end of file +1.17.4 \ No newline at end of file From 68d672c60e9232363061b6e2e99754b009476ec5 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Sun, 23 Apr 2023 03:01:45 +0200 Subject: [PATCH 093/131] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 18ed143..cc2568c 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ This project uses the Winget tool to daily update apps (with system context) and ![image](https://user-images.githubusercontent.com/96626929/150645599-9460def4-0818-4fe9-819c-dd7081ff8447.png) ## Intallation -Just [download latest release (source code)](https://github.com/Romanitho/Winget-AutoUpdate/releases), unzip, run "install.bat" as admin to install by default. +Just [download latest release (WAU.zip)](https://github.com/Romanitho/Winget-AutoUpdate/releases), unzip, run "install.bat" as admin to install by default. ## Configurations ### Keep some apps out of Winget-AutoUpdate From f3b8af08fa31b6ca0fe295e2d185e5aea6f25dde Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Sun, 23 Apr 2023 10:34:25 +0200 Subject: [PATCH 094/131] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cc2568c..aa7073e 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ This project uses the Winget tool to daily update apps (with system context) and ![image](https://user-images.githubusercontent.com/96626929/150645599-9460def4-0818-4fe9-819c-dd7081ff8447.png) ## Intallation -Just [download latest release (WAU.zip)](https://github.com/Romanitho/Winget-AutoUpdate/releases), unzip, run "install.bat" as admin to install by default. +Just [download latest release (WAU.zip)](https://github.com/Romanitho/Winget-AutoUpdate/releases/latest/download/WAU.zip), unzip, run "install.bat" as admin to install by default. ## Configurations ### Keep some apps out of Winget-AutoUpdate From 65f97c8a024b836e05b90098bcd3d59826410d8d Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Sun, 23 Apr 2023 16:14:46 +0200 Subject: [PATCH 095/131] 1st approach --- Winget-AutoUpdate/User-Run.ps1 | 18 +++++++-------- Winget-AutoUpdate/Winget-Upgrade.ps1 | 23 +++++++++++++++++++ .../functions/Invoke-UserApproval.ps1 | 23 ++++++++++--------- 3 files changed, 43 insertions(+), 21 deletions(-) diff --git a/Winget-AutoUpdate/User-Run.ps1 b/Winget-AutoUpdate/User-Run.ps1 index a3b753c..199e1f7 100644 --- a/Winget-AutoUpdate/User-Run.ps1 +++ b/Winget-AutoUpdate/User-Run.ps1 @@ -21,8 +21,7 @@ https://github.com/Romanitho/Winget-AutoUpdate param( [Parameter(Mandatory = $False)] [Switch] $Logs = $false, [Parameter(Mandatory = $False)] [Switch] $Help = $false, - [Parameter(Mandatory = $False)] [Switch] $NotifApprovedAsSystem = $false, - [Parameter(Mandatory = $False)] [Switch] $NotifApprovedAsUser = $false + [Parameter(Mandatory = $False)] [String] $NotifApproved, ) function Test-WAUisRunning { @@ -61,17 +60,16 @@ if ($Logs) { elseif ($Help) { Start-Process "https://github.com/Romanitho/Winget-AutoUpdate" } -elseif ($NotifApprovedAsUser){ +elseif ($NotifApproved){ #Create tag if user approve notif for requested updates $WAUNotifApprovedPath = "$WingetUpdatePath\config\NotifApproved.txt" New-Item $WAUNotifApprovedPath -Force - Get-ScheduledTask -TaskName "Winget-AutoUpdate-UserContext" -ErrorAction SilentlyContinue | Start-ScheduledTask -ErrorAction SilentlyContinue -} -elseif ($NotifApprovedAsSystem){ - #Create tag if user approve notif for requested updates - $WAUNotifApprovedPath = "$WingetUpdatePath\config\NotifApproved.txt" - New-Item $WAUNotifApprovedPath -Force - Get-ScheduledTask -TaskName "Winget-AutoUpdate" -ErrorAction SilentlyContinue | Start-ScheduledTask -ErrorAction SilentlyContinue + if ($NotifApproved -like "*system"){ + Get-ScheduledTask -TaskName "Winget-AutoUpdate" -ErrorAction Stop | Start-ScheduledTask -ErrorAction Stop + } + else{ + Get-ScheduledTask -TaskName "Winget-AutoUpdate-UserContext" -ErrorAction Stop | Start-ScheduledTask -ErrorAction Stop + } } else { try { diff --git a/Winget-AutoUpdate/Winget-Upgrade.ps1 b/Winget-AutoUpdate/Winget-Upgrade.ps1 index 3b2e8e0..81e35cb 100644 --- a/Winget-AutoUpdate/Winget-Upgrade.ps1 +++ b/Winget-AutoUpdate/Winget-Upgrade.ps1 @@ -236,6 +236,29 @@ if (Test-Network) { $Log | out-file -filepath $LogFile -Append } + #Ask user to approve, if configured + if ($WAUConfig.WAU_UserApproval -eq 1){ + Write-Log "User Approval feature enabled." + + #Check for approved tag + $WAUNotifApproved = "$WorkingDir/Config/NotifApproved.txt" + if (Test-Path $WAUNotifApproved) { + Write-Log "-> User approved notification." + Remove-Item $WAUNotifApproved -Force -Confirm:$false + } + else { + $UserApprovalReturn = Invoke-UserApproval $outdated + if ($UserApprovalReturn -eq 0){ + Write-Log "-> User approval requested. Waiting for user to approve available updates... Closing for now." + #Closing job, waiting for user approval + Exit 0 + } + else{ + Write-log "-> No update to request to user." + } + } + } + #Count good update installations $Script:InstallOK = 0 diff --git a/Winget-AutoUpdate/functions/Invoke-UserApproval.ps1 b/Winget-AutoUpdate/functions/Invoke-UserApproval.ps1 index ee9f986..905324d 100644 --- a/Winget-AutoUpdate/functions/Invoke-UserApproval.ps1 +++ b/Winget-AutoUpdate/functions/Invoke-UserApproval.ps1 @@ -3,19 +3,20 @@ function Invoke-UserApproval ($outdated){ #Create / Update WAU Class for notification action - $WAUClass = "HKLM:\Software\Classes\WAU" - $WAUClassCmd = "$WAUClass\shell\open\command" - if ($IsSystem){ - $WAUClassRun = "Wscript.exe ""$WingetUpdatePath\Invisible.vbs"" ""powershell.exe -NoProfile -ExecutionPolicy Bypass -File '$WingetUpdatePath\User-Run.ps1' -NotifApprovedAsSystem" + if ($IsSystem) { + $WAUClass = "HKLM:\Software\Classes\WAU" + $WAUClassCmd = "$WAUClass\shell\open\command" + $WAUClassRun = "Wscript.exe ""$WingetUpdatePath\Invisible.vbs"" ""powershell.exe -NoProfile -ExecutionPolicy Bypass -Command & '$WingetUpdatePath\User-Run.ps1' -NotifApproved %1""" + New-Item $WAUClassCmd -Force -ErrorAction SilentlyContinue | Out-Null + New-ItemProperty -LiteralPath $WAUClass -Name 'URL Protocol' -Value '' -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null + New-ItemProperty -LiteralPath $WAUClass -Name '(default)' -Value "URL:$($ActionType)" -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null + New-ItemProperty -LiteralPath $WAUClass -Name 'EditFlags' -Value '2162688' -PropertyType DWord -Force -ErrorAction SilentlyContinue | Out-Null + New-ItemProperty -LiteralPath $WAUClassCmd -Name '(default)' -Value $WAUClassRun -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null + $Button1Action = "wau:system" } else{ - $WAUClassRun = "Wscript.exe ""$WingetUpdatePath\Invisible.vbs"" ""powershell.exe -NoProfile -ExecutionPolicy Bypass -File '$WingetUpdatePath\User-Run.ps1' -NotifApprovedAsUser" + $Button1Action = "wau:user" } - New-Item $WAUClassCmd -Force -ErrorAction SilentlyContinue | Out-Null - New-ItemProperty -LiteralPath $WAUClass -Name 'URL Protocol' -Value '' -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null - New-ItemProperty -LiteralPath $WAUClass -Name '(default)' -Value "URL:$($ActionType)" -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null - New-ItemProperty -LiteralPath $WAUClass -Name 'EditFlags' -Value '2162688' -PropertyType DWord -Force -ErrorAction SilentlyContinue | Out-Null - New-ItemProperty -LiteralPath $WAUClassCmd -Name '(default)' -Value $WAUClassRun -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null $OutdatedApps = @() #If White List @@ -40,7 +41,7 @@ function Invoke-UserApproval ($outdated){ $body = $OutdatedApps | Out-String if ($body) { #Ask user to update apps - Start-NotifTask -Title "New available updates" -Message "Do you want to update these apps ?" -Body $body -ButtonDismiss -Button1Text "Yes" -Button1Action "wau:1" -MessageType "info" + Start-NotifTask -Title "New available updates" -Message "Do you want to update these apps ?" -Body $body -ButtonDismiss -Button1Text "Yes" -Button1Action $Button1Action -MessageType "info" Return 0 } else { From 65212e6dc07cccafa98d2c68486cb351b45c20c6 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Sun, 23 Apr 2023 16:21:28 +0200 Subject: [PATCH 096/131] new param --- Winget-AutoUpdate-Install.ps1 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Winget-AutoUpdate-Install.ps1 b/Winget-AutoUpdate-Install.ps1 index 7baece4..930e1ad 100644 --- a/Winget-AutoUpdate-Install.ps1 +++ b/Winget-AutoUpdate-Install.ps1 @@ -111,6 +111,7 @@ param( [Parameter(Mandatory = $False)] [DateTime] $UpdatesAtTime = ("06am"), [Parameter(Mandatory = $False)] [Switch] $BypassListForUsers = $false, [Parameter(Mandatory = $False)] [Switch] $InstallUserContext = $false, + [Parameter(Mandatory = $False)] [Switch] $WAU_UserApproval= $false, [Parameter(Mandatory = $False)] [ValidateRange(0, 99)] [int32] $MaxLogFiles = 3, [Parameter(Mandatory = $False)] [int64] $MaxLogSize = 1048576 # in bytes, default is 1048576 = 1 MB ) @@ -373,6 +374,9 @@ function Install-WingetAutoUpdate { if ($BypassListForUsers) { New-ItemProperty $regPath -Name WAU_BypassListForUsers -Value 1 -PropertyType DWord -Force | Out-Null } + if ($WAU_UserApproval) { + New-ItemProperty $regPath -Name WAU_UserApproval -Value 1 -PropertyType DWord -Force | Out-Null + } #Log file and symlink initialization . "$WingetUpdatePath\functions\Start-Init.ps1" From 4a798d02e4ffe6295f80783b6a66d4cb1be7b244 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Sun, 23 Apr 2023 16:22:57 +0200 Subject: [PATCH 097/131] doc --- README.md | 105 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 54 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index aa7073e..0df75ce 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ By default, scripts and components will be placed in ProgramData location (insid From version 1.9.0 (on new installations) WAU runs everyday at 6AM. You can now configure the frequency with `-UpdatesInterval` option (Daily, BiDaily, Weekly, BiWeekly or Monthly). You can also add `-UpdatesAtLogon` parameter to run at user logon and keep this option activated like previous versions (recommanded). ### Log location -You can find logs in install location, in logs folder. +You can find logs in install location, in logs folder. If **Intune Management Extension** is installed, a **SymLink** (WAU-updates.log) is created under **C:\ProgramData\Microsoft\IntuneManagementExtension\Logs** ### "Unknown" App version @@ -59,55 +59,55 @@ A new Auto-Update process has been released from version 1.5.0. By default, WAU To disable WAU AutoUpdate, run the `Winget-AutoUpdate-Install.ps1` with `-DisableWAUAutoUpdate` parameter. ## Uninstall WAU -Simply uninstall it from your programs: +Simply uninstall it from your programs: ![image](https://user-images.githubusercontent.com/96626929/170879336-ef034956-4778-41f0-b8fd-d307b77b70a9.png) ## GUI installation -[WiGui](https://github.com/Romanitho/Winget-Install-GUI/) can be used to install WAU even easier: +[WiGui](https://github.com/Romanitho/Winget-Install-GUI/) can be used to install WAU even easier: ## Advanced installation You can run the `Winget-AutoUpdate-Install.ps1` script with parameters : -**-Silent** +**-Silent** Install Winget-AutoUpdate and prerequisites silently. -**-MaxLogFiles** -Specify number of allowed log files. -Default is 3 out of 0-99: -Setting MaxLogFiles to 0 don't delete any old archived log files. +**-MaxLogFiles** +Specify number of allowed log files. +Default is 3 out of 0-99: +Setting MaxLogFiles to 0 don't delete any old archived log files. Setting it to 1 keeps the original one and just let it grow. -**-MaxLogSize** -Specify the size of the log file in bytes before rotating. +**-MaxLogSize** +Specify the size of the log file in bytes before rotating. Default is 1048576 = 1 MB (ca. 7500 lines) -**-WingetUpdatePath** +**-WingetUpdatePath** Specify Winget-AutoUpdate installation location. Default: `C:\ProgramData\Winget-AutoUpdate` (Recommended to leave default). -**-DoNotUpdate** +**-DoNotUpdate** Do not run Winget-AutoUpdate after installation. By default, Winget-AutoUpdate is run just after installation. -**-DisableWAUAutoUpdate** +**-DisableWAUAutoUpdate** Disable Winget-AutoUpdate update checking. By default, WAU auto updates if new version is available on Github. -**-UseWhiteList** +**-UseWhiteList** Use White List instead of Black List. This setting will not create the "excluded_apps.txt" but "included_apps.txt". -**-ListPath** -Get Black/White List from external Path (**URL/UNC/Local/GPO**) - download/copy to Winget-AutoUpdate installation location if external list is newer. -**PATH** must end with a Directory, not a File... +**-ListPath** +Get Black/White List from external Path (**URL/UNC/Local/GPO**) - download/copy to Winget-AutoUpdate installation location if external list is newer. +**PATH** must end with a Directory, not a File... ...if the external Path is an **URL** and the web host doesn't respond with a date/time header for the file (i.e **GitHub**) then the file is always downloaded! -If `-ListPath` is set to **GPO** the Black/White List can be managed from within the GPO itself under **Application GPO Blacklist**/**Application GPO Whitelist**. +If `-ListPath` is set to **GPO** the Black/White List can be managed from within the GPO itself under **Application GPO Blacklist**/**Application GPO Whitelist**. Thanks to [Weatherlights](https://github.com/Weatherlights) in [#256 (reply in thread)](https://github.com/Romanitho/Winget-AutoUpdate/discussions/256#discussioncomment-4710599)! -**-ModsPath** -Get Mods from external Path (**URL/UNC/Local/AzureBlob**) - download/copy to `mods` in Winget-AutoUpdate installation location if external mods are newer. +**-ModsPath** +Get Mods from external Path (**URL/UNC/Local/AzureBlob**) - download/copy to `mods` in Winget-AutoUpdate installation location if external mods are newer. -For **URL**: This requires a site directory with **Directory Listing Enabled** and no index page overriding the listing of files (or an index page with href listing of all the **Mods** to be downloaded): +For **URL**: This requires a site directory with **Directory Listing Enabled** and no index page overriding the listing of files (or an index page with href listing of all the **Mods** to be downloaded): ``` ``` -Validated on **IIS/Apache**. +Validated on **IIS/Apache**. -**Nota bene IIS** : +**Nota bene IIS** : - The extension **.ps1** must be added as **MIME Types** (text/powershell-script) otherwise it's displayed in the listing but can't be opened - Files with special characters in the filename can't be opened by default from an IIS server - config must be administrated: **Enable Allow double escaping** in '**Request Filtering**' @@ -127,37 +127,40 @@ For **AzureBlob**: This requires the parameter **-AzureBlobURL** to be set with **-AzureBlobURL** Used in conjunction with the **-ModsPath** parameter to provide the Azure Storage Blob URL with SAS token. The SAS token must, at a minimum, have 'Read' and 'List' permissions. It is recommended to set the permisions at the container level and rotate the SAS token on a regular basis. Ensure the container reflects the same structure as found under the initial `mods` folder. (From version 1.16.4). -**-InstallUserContext** +**-InstallUserContext** Install WAU with system and **user** context executions (From version 1.15.3). -**-BypassListForUsers** +**-BypassListForUsers** Bypass Black/White list when run in user context (From version 1.15.0). -**-NoClean** +**-NoClean** Keep critical files when installing/uninstalling. This setting will keep "excluded_apps.txt", "included_apps.txt", "mods" and "logs" as they were. -**-DesktopShortcut** +**-DesktopShortcut** Create a shortcut for user interaction on the Desktop to run task `Winget-AutoUpdate` (From version 1.15.0). -**-StartMenuShortcut** +**-StartMenuShortcut** Create shortcuts for user interaction in the Start Menu to run task `Winget-AutoUpdate`, open Logs and Web Help (From version 1.15.0). -**-NotificationLevel** +**-NotificationLevel** Specify the Notification level: Full (Default, displays all notification), SuccessOnly (Only displays notification for success) or None (Does not show any popup). -**-UpdatesAtLogon** +**-UpdatesAtLogon** Set WAU to run at user logon. -**-UpdatesInterval** +**-UpdatesInterval** Specify the update frequency: Daily (Default), BiDaily, Weekly, BiWeekly, Monthly or Never. Can be set to 'Never' in combination with '-UpdatesAtLogon' for instance. -**-UpdatesAtTime** +**-UpdatesAtTime** Specify the time of the update interval execution time. Default 6AM. (From version 1.15.0). -**-RunOnMetered** +**WAU_UserApproval** +Specify if user approval is needed before updating apps + +**-RunOnMetered** Run WAU on metered connection. Default No. -**-Uninstall** +**-Uninstall** Remove scheduled tasks and scripts. ## Intune/SCCM use @@ -165,38 +168,38 @@ See https://github.com/Romanitho/Winget-AutoUpdate/discussions/88 ## Custom scripts (Mods feature) From version 1.8.0, the Mods feature allows you to run additional scripts when upgrading or installing an app. -Just put the scripts in question with the **AppID** followed by the `-preinstall`, `-upgrade`, `-install` or `-installed` suffix in the **mods** folder. -> Runs before upgrade/install: `AppID-preinstall.ps1` -> Runs during upgrade/install (before install check): `AppID-upgrade.ps1`/`AppID-install.ps1` -> Runs after upgrade/install has been confirmed: `AppID-installed.ps1` +Just put the scripts in question with the **AppID** followed by the `-preinstall`, `-upgrade`, `-install` or `-installed` suffix in the **mods** folder. +> Runs before upgrade/install: `AppID-preinstall.ps1` +> Runs during upgrade/install (before install check): `AppID-upgrade.ps1`/`AppID-install.ps1` +> Runs after upgrade/install has been confirmed: `AppID-installed.ps1` -The **-install** mod will be used for upgrades too if **-upgrade** doesn't exist (**WAU** first tries `& $Winget upgrade --id` and if the app isn't detected after that `& $Winget install --id` is tried). -`AppID-install.ps1` is recommended because it's used in **both** scenarios. +The **-install** mod will be used for upgrades too if **-upgrade** doesn't exist (**WAU** first tries `& $Winget upgrade --id` and if the app isn't detected after that `& $Winget install --id` is tried). +`AppID-install.ps1` is recommended because it's used in **both** scenarios. -> Example: +> Example: If you want to run a script that removes the shortcut from **%PUBLIC%\Desktop** (we don't want to fill the desktop with shortcuts our users can't delete) just after installing **Acrobat Reader DC** (32-bit), prepare a powershell script that removes the Public Desktop shortcut **Acrobat Reader DC.lnk** and name your script like this: `Adobe.Acrobat.Reader.32-bit-installed.ps1` and put it in the **mods** folder. -You can find more information on [Winget-Install Repo](https://github.com/Romanitho/Winget-Install#custom-mods), as it's a related feature. +You can find more information on [Winget-Install Repo](https://github.com/Romanitho/Winget-Install#custom-mods), as it's a related feature. Read more in the `README.md` under the directory **mods**. -Share your mods with the community: +Share your mods with the community: https://github.com/Romanitho/Winget-AutoUpdate/discussions/categories/mods ### Winget native parameters Another finess is the **AppID** followed by the `-override` suffix as a **text file** (.**txt**) that you can place under the **mods** folder. -> Example: +> Example: > **Canneverbe.CDBurnerXP-override.txt** with the content `ADDLOCAL=All REMOVE=Desktop_Shortcut /qn` -This will use the **content** of the text file as a native **winget --override** parameter when upgrading (as proposed by [JonNesovic](https://github.com/JonNesovic) in [Mod for --override argument #244](https://github.com/Romanitho/Winget-AutoUpdate/discussions/244#discussion-4637666)). +This will use the **content** of the text file as a native **winget --override** parameter when upgrading (as proposed by [JonNesovic](https://github.com/JonNesovic) in [Mod for --override argument #244](https://github.com/Romanitho/Winget-AutoUpdate/discussions/244#discussion-4637666)). ## GPO Management -In an enterprise environment it's crucial that different groups can have different settings in applications etc. or to implement other mandatory settings, i.e for security/management reasons. -**WAU** doesn't have any setting that can be changed except for when installing (or editing the registry/the task `Winget-AutoUpdate` as **Admin**). -With the use of **ADML/ADMX** files you can manage every **WAU** setting from within **GPO**. -They will be detected/evaluated during the next run of **WAU** (taking effect before any actions). -The **GPO ADMX/ADML** validated with: -[Windows 10 - Validate ADMX for Ingestion](https://developer.vmware.com/samples/7115/windows-10---validate-admx-for-ingestion) +In an enterprise environment it's crucial that different groups can have different settings in applications etc. or to implement other mandatory settings, i.e for security/management reasons. +**WAU** doesn't have any setting that can be changed except for when installing (or editing the registry/the task `Winget-AutoUpdate` as **Admin**). +With the use of **ADML/ADMX** files you can manage every **WAU** setting from within **GPO**. +They will be detected/evaluated during the next run of **WAU** (taking effect before any actions). +The **GPO ADMX/ADML** validated with: +[Windows 10 - Validate ADMX for Ingestion](https://developer.vmware.com/samples/7115/windows-10---validate-admx-for-ingestion) Read more in the `README.md` under the directory **Policies**. ![image](https://user-images.githubusercontent.com/102996177/213920242-7ff8e2b4-d926-4407-b860-1e5922e29c3e.png) From 0363e21edbea33b43e83c06fd5b4c17d6fcada17 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Sun, 23 Apr 2023 16:25:05 +0200 Subject: [PATCH 098/131] details --- README.md | 2 +- Winget-AutoUpdate-Install.ps1 | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0df75ce..6aea834 100644 --- a/README.md +++ b/README.md @@ -154,7 +154,7 @@ Specify the update frequency: Daily (Default), BiDaily, Weekly, BiWeekly, Monthl **-UpdatesAtTime** Specify the time of the update interval execution time. Default 6AM. (From version 1.15.0). -**WAU_UserApproval** +**-UserApproval** Specify if user approval is needed before updating apps **-RunOnMetered** diff --git a/Winget-AutoUpdate-Install.ps1 b/Winget-AutoUpdate-Install.ps1 index 930e1ad..cf62b27 100644 --- a/Winget-AutoUpdate-Install.ps1 +++ b/Winget-AutoUpdate-Install.ps1 @@ -67,6 +67,9 @@ Run WAU on metered connection. Default No. .PARAMETER InstallUserContext Install WAU with system and user context executions +.PARAMETER UserApproval +Specify if user approval is needed before updating apps + .PARAMETER BypassListForUsers Configure WAU to bypass the Black/White list when run in user context @@ -374,7 +377,7 @@ function Install-WingetAutoUpdate { if ($BypassListForUsers) { New-ItemProperty $regPath -Name WAU_BypassListForUsers -Value 1 -PropertyType DWord -Force | Out-Null } - if ($WAU_UserApproval) { + if ($UserApproval) { New-ItemProperty $regPath -Name WAU_UserApproval -Value 1 -PropertyType DWord -Force | Out-Null } From 7aea648d462897d6fb9c3afe646291d6f630a521 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Sun, 23 Apr 2023 16:29:05 +0200 Subject: [PATCH 099/131] detail2 --- Winget-AutoUpdate-Install.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Winget-AutoUpdate-Install.ps1 b/Winget-AutoUpdate-Install.ps1 index cf62b27..37ef98d 100644 --- a/Winget-AutoUpdate-Install.ps1 +++ b/Winget-AutoUpdate-Install.ps1 @@ -114,7 +114,7 @@ param( [Parameter(Mandatory = $False)] [DateTime] $UpdatesAtTime = ("06am"), [Parameter(Mandatory = $False)] [Switch] $BypassListForUsers = $false, [Parameter(Mandatory = $False)] [Switch] $InstallUserContext = $false, - [Parameter(Mandatory = $False)] [Switch] $WAU_UserApproval= $false, + [Parameter(Mandatory = $False)] [Switch] $UserApproval= $false, [Parameter(Mandatory = $False)] [ValidateRange(0, 99)] [int32] $MaxLogFiles = 3, [Parameter(Mandatory = $False)] [int64] $MaxLogSize = 1048576 # in bytes, default is 1048576 = 1 MB ) From a16313b367ed3d529cddab54768c18fa21b4b0d8 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Sun, 23 Apr 2023 17:00:25 +0200 Subject: [PATCH 100/131] Write-ToLog --- Winget-AutoUpdate/User-Run.ps1 | 7 +++++-- Winget-AutoUpdate/Winget-Upgrade.ps1 | 8 ++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Winget-AutoUpdate/User-Run.ps1 b/Winget-AutoUpdate/User-Run.ps1 index 199e1f7..ff71dfb 100644 --- a/Winget-AutoUpdate/User-Run.ps1 +++ b/Winget-AutoUpdate/User-Run.ps1 @@ -21,7 +21,7 @@ https://github.com/Romanitho/Winget-AutoUpdate param( [Parameter(Mandatory = $False)] [Switch] $Logs = $false, [Parameter(Mandatory = $False)] [Switch] $Help = $false, - [Parameter(Mandatory = $False)] [String] $NotifApproved, + [Parameter(Mandatory = $False)] [String] $NotifApproved ) function Test-WAUisRunning { @@ -103,7 +103,10 @@ else { $MessageType = "success" $Message = $NotifLocale.local.outputs.output[9].message } - Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss -UserRun + $IsUserApprovalEnable = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name WAU_UserApproval -ErrorAction SilentlyContinue).WAU_UserApproval + if ($IsUserApprovalEnable -ne "1"){ + Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss -UserRun + } } catch { #Check failed - Just send notification diff --git a/Winget-AutoUpdate/Winget-Upgrade.ps1 b/Winget-AutoUpdate/Winget-Upgrade.ps1 index 81e35cb..dbba189 100644 --- a/Winget-AutoUpdate/Winget-Upgrade.ps1 +++ b/Winget-AutoUpdate/Winget-Upgrade.ps1 @@ -238,23 +238,23 @@ if (Test-Network) { #Ask user to approve, if configured if ($WAUConfig.WAU_UserApproval -eq 1){ - Write-Log "User Approval feature enabled." + Write-ToLog "User Approval feature enabled." #Check for approved tag $WAUNotifApproved = "$WorkingDir/Config/NotifApproved.txt" if (Test-Path $WAUNotifApproved) { - Write-Log "-> User approved notification." + Write-ToLog "-> User approved notification." Remove-Item $WAUNotifApproved -Force -Confirm:$false } else { $UserApprovalReturn = Invoke-UserApproval $outdated if ($UserApprovalReturn -eq 0){ - Write-Log "-> User approval requested. Waiting for user to approve available updates... Closing for now." + Write-ToLog "-> User approval requested. Waiting for user to approve available updates... Closing for now." #Closing job, waiting for user approval Exit 0 } else{ - Write-log "-> No update to request to user." + Write-ToLog "-> No update to request to user." } } } From 881ce2ddc1043dfe8674e172f194b55244545c5d Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Sun, 23 Apr 2023 17:03:35 +0200 Subject: [PATCH 101/131] WorkingDir --- Winget-AutoUpdate/functions/Invoke-UserApproval.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Winget-AutoUpdate/functions/Invoke-UserApproval.ps1 b/Winget-AutoUpdate/functions/Invoke-UserApproval.ps1 index 905324d..fbcc78d 100644 --- a/Winget-AutoUpdate/functions/Invoke-UserApproval.ps1 +++ b/Winget-AutoUpdate/functions/Invoke-UserApproval.ps1 @@ -6,7 +6,7 @@ function Invoke-UserApproval ($outdated){ if ($IsSystem) { $WAUClass = "HKLM:\Software\Classes\WAU" $WAUClassCmd = "$WAUClass\shell\open\command" - $WAUClassRun = "Wscript.exe ""$WingetUpdatePath\Invisible.vbs"" ""powershell.exe -NoProfile -ExecutionPolicy Bypass -Command & '$WingetUpdatePath\User-Run.ps1' -NotifApproved %1""" + $WAUClassRun = "Wscript.exe ""$WorkingDir\Invisible.vbs"" ""powershell.exe -NoProfile -ExecutionPolicy Bypass -Command & '$WorkingDir\User-Run.ps1' -NotifApproved %1""" New-Item $WAUClassCmd -Force -ErrorAction SilentlyContinue | Out-Null New-ItemProperty -LiteralPath $WAUClass -Name 'URL Protocol' -Value '' -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null New-ItemProperty -LiteralPath $WAUClass -Name '(default)' -Value "URL:$($ActionType)" -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null From 74856cdecc7598715fd473e0cc7ea5543b63d9c9 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Mon, 24 Apr 2023 01:49:20 +0200 Subject: [PATCH 102/131] testing --- Winget-AutoUpdate/User-Run.ps1 | 38 ++++++++++++++----- Winget-AutoUpdate/Winget-Upgrade.ps1 | 2 +- .../functions/Invoke-UserApproval.ps1 | 13 +++++-- 3 files changed, 40 insertions(+), 13 deletions(-) diff --git a/Winget-AutoUpdate/User-Run.ps1 b/Winget-AutoUpdate/User-Run.ps1 index ff71dfb..a3e2057 100644 --- a/Winget-AutoUpdate/User-Run.ps1 +++ b/Winget-AutoUpdate/User-Run.ps1 @@ -61,13 +61,33 @@ elseif ($Help) { Start-Process "https://github.com/Romanitho/Winget-AutoUpdate" } elseif ($NotifApproved){ - #Create tag if user approve notif for requested updates - $WAUNotifApprovedPath = "$WingetUpdatePath\config\NotifApproved.txt" - New-Item $WAUNotifApprovedPath -Force - if ($NotifApproved -like "*system"){ + $MessageBody = "Do you want to update these apps ?`n`n" + $MessageBody += Get-Content "$WorkingDir/config/NotifContent.txt" -Raw + $Title = "Winget-AutoUpdate" + if ($NotifApproved -eq "wau:systemDialogBox"){ + Add-Type -AssemblyName PresentationCore,PresentationFramework + $Result = [System.Windows.MessageBox]::Show($MessageBody,$Title,4,32) + if ($Result -eq "Yes") { + $NotifApproved = "wau:system" + } + } + if ($NotifApproved -eq "wau:userDialogBox"){ + Add-Type -AssemblyName PresentationCore,PresentationFramework + $Result = [System.Windows.MessageBox]::Show($MessageBody,$Title,4,32) + if ($Result -eq "Yes") { + $NotifApproved = "wau:user" + } + } + if ($NotifApproved -eq "wau:system"){ + #Create tag if user approve notif for requested updates + $WAUNotifApprovedPath = "$WorkingDir\config\NotifApproved.txt" + New-Item $WAUNotifApprovedPath -Force Get-ScheduledTask -TaskName "Winget-AutoUpdate" -ErrorAction Stop | Start-ScheduledTask -ErrorAction Stop } - else{ + if ($NotifApproved -eq "wau:user"){ + #Create tag if user approve notif for requested updates + $WAUNotifApprovedPath = "$WorkingDir\config\NotifApproved.txt" + New-Item $WAUNotifApprovedPath -Force Get-ScheduledTask -TaskName "Winget-AutoUpdate-UserContext" -ErrorAction Stop | Start-ScheduledTask -ErrorAction Stop } } @@ -77,7 +97,7 @@ else { if (Test-WAUisRunning) { $Message = $NotifLocale.local.outputs.output[8].message $MessageType = "warning" - Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss -UserRun + Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -UserRun break } #Run scheduled task @@ -85,7 +105,7 @@ else { #Starting check - Send notification $Message = $NotifLocale.local.outputs.output[6].message $MessageType = "info" - Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss -UserRun + Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -UserRun #Sleep until the task is done While (Test-WAUisRunning) { Start-Sleep 3 @@ -105,13 +125,13 @@ else { } $IsUserApprovalEnable = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name WAU_UserApproval -ErrorAction SilentlyContinue).WAU_UserApproval if ($IsUserApprovalEnable -ne "1"){ - Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss -UserRun + Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -UserRun } } catch { #Check failed - Just send notification $Message = $NotifLocale.local.outputs.output[7].message $MessageType = "error" - Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss -UserRun + Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -UserRun } } diff --git a/Winget-AutoUpdate/Winget-Upgrade.ps1 b/Winget-AutoUpdate/Winget-Upgrade.ps1 index dbba189..461b7dc 100644 --- a/Winget-AutoUpdate/Winget-Upgrade.ps1 +++ b/Winget-AutoUpdate/Winget-Upgrade.ps1 @@ -243,7 +243,7 @@ if (Test-Network) { #Check for approved tag $WAUNotifApproved = "$WorkingDir/Config/NotifApproved.txt" if (Test-Path $WAUNotifApproved) { - Write-ToLog "-> User approved notification." + Write-ToLog "-> User approved notification." Remove-Item $WAUNotifApproved -Force -Confirm:$false } else { diff --git a/Winget-AutoUpdate/functions/Invoke-UserApproval.ps1 b/Winget-AutoUpdate/functions/Invoke-UserApproval.ps1 index fbcc78d..4b2f8c7 100644 --- a/Winget-AutoUpdate/functions/Invoke-UserApproval.ps1 +++ b/Winget-AutoUpdate/functions/Invoke-UserApproval.ps1 @@ -13,9 +13,11 @@ function Invoke-UserApproval ($outdated){ New-ItemProperty -LiteralPath $WAUClass -Name 'EditFlags' -Value '2162688' -PropertyType DWord -Force -ErrorAction SilentlyContinue | Out-Null New-ItemProperty -LiteralPath $WAUClassCmd -Name '(default)' -Value $WAUClassRun -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null $Button1Action = "wau:system" + $OnClickAction = "wau:systemDialogBox" } else{ $Button1Action = "wau:user" + $OnClickAction = "wau:userDialogBox" } $OutdatedApps = @() @@ -24,7 +26,7 @@ function Invoke-UserApproval ($outdated){ $toUpdate = Get-IncludedApps foreach ($app in $Outdated) { if (($toUpdate -contains $app.Id) -and $($app.Version) -ne "Unknown") { - $OutdatedApps += $app.Name + $OutdatedApps += "- $($app.Name)" } } } @@ -33,7 +35,7 @@ function Invoke-UserApproval ($outdated){ $toSkip = Get-ExcludedApps foreach ($app in $Outdated) { if (-not ($toSkip -contains $app.Id) -and $($app.Version) -ne "Unknown") { - $OutdatedApps += $app.Name + $OutdatedApps += "- $($app.Name)" } } } @@ -41,7 +43,12 @@ function Invoke-UserApproval ($outdated){ $body = $OutdatedApps | Out-String if ($body) { #Ask user to update apps - Start-NotifTask -Title "New available updates" -Message "Do you want to update these apps ?" -Body $body -ButtonDismiss -Button1Text "Yes" -Button1Action $Button1Action -MessageType "info" + $Message = "Do you want to update these apps ?" + $body += "`nPlease save your work and close theses apps" + $WAUNotifContent = "$WorkingDir\config\NotifContent.txt" + New-Item -Path $WAUNotifContent -ItemType File -Force | Out-Null + Set-Content -Path $WAUNotifContent -Value $body + Start-NotifTask -Title "New available updates" -Message $Message -Body $body -ButtonDismiss -Button1Text "Yes" -Button1Action $Button1Action -OnClickAction $OnClickAction -MessageType "info" Return 0 } else { From 59bb6055aadb953fc7b83cea70ef4c023a4ef4d4 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Tue, 25 Apr 2023 00:43:04 +0200 Subject: [PATCH 103/131] Update Start-NotifTask.ps1 --- Winget-AutoUpdate/functions/Start-NotifTask.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Winget-AutoUpdate/functions/Start-NotifTask.ps1 b/Winget-AutoUpdate/functions/Start-NotifTask.ps1 index 3aa17d9..6ffae41 100644 --- a/Winget-AutoUpdate/functions/Start-NotifTask.ps1 +++ b/Winget-AutoUpdate/functions/Start-NotifTask.ps1 @@ -15,7 +15,7 @@ function Start-NotifTask { [Switch]$UserRun = $false ) - if (($WAUConfig.WAU_NotificationLevel -eq "Full") -or ($WAUConfig.WAU_NotificationLevel -eq "SuccessOnly" -and $MessageType -eq "Success") -or (!$IsSystem)) { + if (($WAUConfig.WAU_NotificationLevel -eq "Full") -or ($WAUConfig.WAU_NotificationLevel -eq "SuccessOnly" -and $MessageType -eq "Success") -or ($UserRun)) { # XML Toast template creation [xml]$ToastTemplate = New-Object system.Xml.XmlDocument From 299e4d10f2fa073cc64b6047b06844b35d89a9f2 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Tue, 25 Apr 2023 00:45:47 +0200 Subject: [PATCH 104/131] Update README.md --- README.md | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 6aea834..b46af88 100644 --- a/README.md +++ b/README.md @@ -71,32 +71,32 @@ Simply uninstall it from your programs: ## Advanced installation You can run the `Winget-AutoUpdate-Install.ps1` script with parameters : -**-Silent** +**-Silent** Install Winget-AutoUpdate and prerequisites silently. -**-MaxLogFiles** +**-MaxLogFiles** Specify number of allowed log files. Default is 3 out of 0-99: Setting MaxLogFiles to 0 don't delete any old archived log files. Setting it to 1 keeps the original one and just let it grow. -**-MaxLogSize** +**-MaxLogSize** Specify the size of the log file in bytes before rotating. Default is 1048576 = 1 MB (ca. 7500 lines) -**-WingetUpdatePath** +**-WingetUpdatePath** Specify Winget-AutoUpdate installation location. Default: `C:\ProgramData\Winget-AutoUpdate` (Recommended to leave default). -**-DoNotUpdate** +**-DoNotUpdate** Do not run Winget-AutoUpdate after installation. By default, Winget-AutoUpdate is run just after installation. -**-DisableWAUAutoUpdate** +**-DisableWAUAutoUpdate** Disable Winget-AutoUpdate update checking. By default, WAU auto updates if new version is available on Github. -**-UseWhiteList** +**-UseWhiteList** Use White List instead of Black List. This setting will not create the "excluded_apps.txt" but "included_apps.txt". -**-ListPath** +**-ListPath** Get Black/White List from external Path (**URL/UNC/Local/GPO**) - download/copy to Winget-AutoUpdate installation location if external list is newer. **PATH** must end with a Directory, not a File... ...if the external Path is an **URL** and the web host doesn't respond with a date/time header for the file (i.e **GitHub**) then the file is always downloaded! @@ -104,7 +104,7 @@ Get Black/White List from external Path (**URL/UNC/Local/GPO**) - download/copy If `-ListPath` is set to **GPO** the Black/White List can be managed from within the GPO itself under **Application GPO Blacklist**/**Application GPO Whitelist**. Thanks to [Weatherlights](https://github.com/Weatherlights) in [#256 (reply in thread)](https://github.com/Romanitho/Winget-AutoUpdate/discussions/256#discussioncomment-4710599)! -**-ModsPath** +**-ModsPath** Get Mods from external Path (**URL/UNC/Local/AzureBlob**) - download/copy to `mods` in Winget-AutoUpdate installation location if external mods are newer. For **URL**: This requires a site directory with **Directory Listing Enabled** and no index page overriding the listing of files (or an index page with href listing of all the **Mods** to be downloaded): @@ -118,49 +118,49 @@ For **URL**: This requires a site directory with **Directory Listing Enabled** a ``` Validated on **IIS/Apache**. -**Nota bene IIS** : +**Nota bene IIS** : - The extension **.ps1** must be added as **MIME Types** (text/powershell-script) otherwise it's displayed in the listing but can't be opened - Files with special characters in the filename can't be opened by default from an IIS server - config must be administrated: **Enable Allow double escaping** in '**Request Filtering**' For **AzureBlob**: This requires the parameter **-AzureBlobURL** to be set with an appropriate Azure Blob Storage URL including the SAS token. See **-AzureBlobURL** for more information. -**-AzureBlobURL** +**-AzureBlobURL** Used in conjunction with the **-ModsPath** parameter to provide the Azure Storage Blob URL with SAS token. The SAS token must, at a minimum, have 'Read' and 'List' permissions. It is recommended to set the permisions at the container level and rotate the SAS token on a regular basis. Ensure the container reflects the same structure as found under the initial `mods` folder. (From version 1.16.4). -**-InstallUserContext** +**-InstallUserContext** Install WAU with system and **user** context executions (From version 1.15.3). -**-BypassListForUsers** +**-BypassListForUsers** Bypass Black/White list when run in user context (From version 1.15.0). -**-NoClean** +**-NoClean** Keep critical files when installing/uninstalling. This setting will keep "excluded_apps.txt", "included_apps.txt", "mods" and "logs" as they were. -**-DesktopShortcut** +**-DesktopShortcut** Create a shortcut for user interaction on the Desktop to run task `Winget-AutoUpdate` (From version 1.15.0). -**-StartMenuShortcut** +**-StartMenuShortcut** Create shortcuts for user interaction in the Start Menu to run task `Winget-AutoUpdate`, open Logs and Web Help (From version 1.15.0). -**-NotificationLevel** +**-NotificationLevel** Specify the Notification level: Full (Default, displays all notification), SuccessOnly (Only displays notification for success) or None (Does not show any popup). -**-UpdatesAtLogon** +**-UpdatesAtLogon** Set WAU to run at user logon. -**-UpdatesInterval** +**-UpdatesInterval** Specify the update frequency: Daily (Default), BiDaily, Weekly, BiWeekly, Monthly or Never. Can be set to 'Never' in combination with '-UpdatesAtLogon' for instance. -**-UpdatesAtTime** +**-UpdatesAtTime** Specify the time of the update interval execution time. Default 6AM. (From version 1.15.0). -**-UserApproval** +**-UserApproval** Specify if user approval is needed before updating apps -**-RunOnMetered** +**-RunOnMetered** Run WAU on metered connection. Default No. -**-Uninstall** +**-Uninstall** Remove scheduled tasks and scripts. ## Intune/SCCM use From 3738f5d3db9c634cf78093b1eedee85e6f42716b Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Tue, 25 Apr 2023 00:50:09 +0200 Subject: [PATCH 105/131] Update README.md --- README.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index b46af88..f7bae98 100644 --- a/README.md +++ b/README.md @@ -75,13 +75,13 @@ You can run the `Winget-AutoUpdate-Install.ps1` script with parameters : Install Winget-AutoUpdate and prerequisites silently. **-MaxLogFiles** -Specify number of allowed log files. -Default is 3 out of 0-99: -Setting MaxLogFiles to 0 don't delete any old archived log files. +Specify number of allowed log files. +Default is 3 out of 0-99: +Setting MaxLogFiles to 0 don't delete any old archived log files. Setting it to 1 keeps the original one and just let it grow. **-MaxLogSize** -Specify the size of the log file in bytes before rotating. +Specify the size of the log file in bytes before rotating. Default is 1048576 = 1 MB (ca. 7500 lines) **-WingetUpdatePath** @@ -97,8 +97,8 @@ Disable Winget-AutoUpdate update checking. By default, WAU auto updates if new v Use White List instead of Black List. This setting will not create the "excluded_apps.txt" but "included_apps.txt". **-ListPath** -Get Black/White List from external Path (**URL/UNC/Local/GPO**) - download/copy to Winget-AutoUpdate installation location if external list is newer. -**PATH** must end with a Directory, not a File... +Get Black/White List from external Path (**URL/UNC/Local/GPO**) - download/copy to Winget-AutoUpdate installation location if external list is newer. +**PATH** must end with a Directory, not a File... ...if the external Path is an **URL** and the web host doesn't respond with a date/time header for the file (i.e **GitHub**) then the file is always downloaded! If `-ListPath` is set to **GPO** the Black/White List can be managed from within the GPO itself under **Application GPO Blacklist**/**Application GPO Whitelist**. @@ -194,12 +194,12 @@ Another finess is the **AppID** followed by the `-override` suffix as a **text f This will use the **content** of the text file as a native **winget --override** parameter when upgrading (as proposed by [JonNesovic](https://github.com/JonNesovic) in [Mod for --override argument #244](https://github.com/Romanitho/Winget-AutoUpdate/discussions/244#discussion-4637666)). ## GPO Management -In an enterprise environment it's crucial that different groups can have different settings in applications etc. or to implement other mandatory settings, i.e for security/management reasons. -**WAU** doesn't have any setting that can be changed except for when installing (or editing the registry/the task `Winget-AutoUpdate` as **Admin**). -With the use of **ADML/ADMX** files you can manage every **WAU** setting from within **GPO**. -They will be detected/evaluated during the next run of **WAU** (taking effect before any actions). -The **GPO ADMX/ADML** validated with: -[Windows 10 - Validate ADMX for Ingestion](https://developer.vmware.com/samples/7115/windows-10---validate-admx-for-ingestion) +In an enterprise environment it's crucial that different groups can have different settings in applications etc. or to implement other mandatory settings, i.e for security/management reasons. +**WAU** doesn't have any setting that can be changed except for when installing (or editing the registry/the task `Winget-AutoUpdate` as **Admin**). +With the use of **ADML/ADMX** files you can manage every **WAU** setting from within **GPO**. +They will be detected/evaluated during the next run of **WAU** (taking effect before any actions). +The **GPO ADMX/ADML** validated with: +[Windows 10 - Validate ADMX for Ingestion](https://developer.vmware.com/samples/7115/windows-10---validate-admx-for-ingestion) Read more in the `README.md` under the directory **Policies**. ![image](https://user-images.githubusercontent.com/102996177/213920242-7ff8e2b4-d926-4407-b860-1e5922e29c3e.png) From 15ff97a43ef284c9bc537957cbba0823086dca4e Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Tue, 25 Apr 2023 00:53:24 +0200 Subject: [PATCH 106/131] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f7bae98..a296d7a 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ By default, scripts and components will be placed in ProgramData location (insid From version 1.9.0 (on new installations) WAU runs everyday at 6AM. You can now configure the frequency with `-UpdatesInterval` option (Daily, BiDaily, Weekly, BiWeekly or Monthly). You can also add `-UpdatesAtLogon` parameter to run at user logon and keep this option activated like previous versions (recommanded). ### Log location -You can find logs in install location, in logs folder. +You can find logs in install location, in logs folder. If **Intune Management Extension** is installed, a **SymLink** (WAU-updates.log) is created under **C:\ProgramData\Microsoft\IntuneManagementExtension\Logs** ### "Unknown" App version @@ -55,7 +55,7 @@ From version 1.15.0, WAU run with system and user contexts. This way, even apps Same process as new installation : download, unzip and run `install.bat`. ### Automatic Update -A new Auto-Update process has been released from version 1.5.0. By default, WAU AutoUpdate is enabled. It will not overwrite the configurations, icons (if personalised), excluded_apps list,... +A new Auto-Update process has been released from version 1.5.0. By default, WAU AutoUpdate is enabled. It will not overwrite the configurations, icons (if personalised), excluded_apps list,... To disable WAU AutoUpdate, run the `Winget-AutoUpdate-Install.ps1` with `-DisableWAUAutoUpdate` parameter. ## Uninstall WAU @@ -101,7 +101,7 @@ Get Black/White List from external Path (**URL/UNC/Local/GPO**) - download/copy **PATH** must end with a Directory, not a File... ...if the external Path is an **URL** and the web host doesn't respond with a date/time header for the file (i.e **GitHub**) then the file is always downloaded! -If `-ListPath` is set to **GPO** the Black/White List can be managed from within the GPO itself under **Application GPO Blacklist**/**Application GPO Whitelist**. +If `-ListPath` is set to **GPO** the Black/White List can be managed from within the GPO itself under **Application GPO Blacklist**/**Application GPO Whitelist**. Thanks to [Weatherlights](https://github.com/Weatherlights) in [#256 (reply in thread)](https://github.com/Romanitho/Winget-AutoUpdate/discussions/256#discussioncomment-4710599)! **-ModsPath** From 4f2a51bf61c760dfed5f5beb36aedbab05483230 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Tue, 25 Apr 2023 00:56:36 +0200 Subject: [PATCH 107/131] update --- Winget-AutoUpdate/User-Run.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Winget-AutoUpdate/User-Run.ps1 b/Winget-AutoUpdate/User-Run.ps1 index a3e2057..35917ec 100644 --- a/Winget-AutoUpdate/User-Run.ps1 +++ b/Winget-AutoUpdate/User-Run.ps1 @@ -71,14 +71,14 @@ elseif ($NotifApproved){ $NotifApproved = "wau:system" } } - if ($NotifApproved -eq "wau:userDialogBox"){ + if ($NotifApproved -eq "wau:userDialogBox"){ Add-Type -AssemblyName PresentationCore,PresentationFramework $Result = [System.Windows.MessageBox]::Show($MessageBody,$Title,4,32) if ($Result -eq "Yes") { $NotifApproved = "wau:user" } } - if ($NotifApproved -eq "wau:system"){ + if ($NotifApproved -eq "wau:system"){ #Create tag if user approve notif for requested updates $WAUNotifApprovedPath = "$WorkingDir\config\NotifApproved.txt" New-Item $WAUNotifApprovedPath -Force From c5d5ee1b5ea83dfabc207ce45b9ffdf3934f7ece Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Wed, 26 Apr 2023 22:43:11 +0200 Subject: [PATCH 108/131] GPO management added --- Policies/WAU.admx | 10 ++++++++++ Policies/en-US/WAU.adml | 10 +++++++--- Winget-AutoUpdate/functions/Get-Policies.ps1 | 9 +++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/Policies/WAU.admx b/Policies/WAU.admx index 3106d8b..db17dd5 100644 --- a/Policies/WAU.admx +++ b/Policies/WAU.admx @@ -349,6 +349,16 @@ + + + + + + + + + + diff --git a/Policies/en-US/WAU.adml b/Policies/en-US/WAU.adml index e9d1f05..85d1a26 100644 --- a/Policies/en-US/WAU.adml +++ b/Policies/en-US/WAU.adml @@ -45,8 +45,8 @@ If "Application GPO Blacklist/Whitelist" is set in this GPO the Path can be: GPO If this policy is disabled or not configured, the default ListPath is used (WAU InstallLocation). Get Mods from external Path (URL/UNC/Local/AzureBlob) - If this policy is enabled, you can set a (URL/UNC/Local/AzureBlob) Path to external mods other than the default. - + If this policy is enabled, you can set a (URL/UNC/Local/AzureBlob) Path to external mods other than the default. + If this policy is disabled or not configured, the default ModsPath is used (WAU InstallLocation). Note: When set to 'AzureBlob', ensure you also configure 'Set Azure Blob URL with SAS token'. @@ -140,6 +140,10 @@ If this policy is disabled or not configured, the default number is used. + Specify if user approval is needed before updating apps + This policy setting specifies whether to require user approval before updatings available application updates . + +If this policy is disabled or not configured, the default is No. @@ -157,7 +161,7 @@ If this policy is disabled or not configured, the default size is used. - + diff --git a/Winget-AutoUpdate/functions/Get-Policies.ps1 b/Winget-AutoUpdate/functions/Get-Policies.ps1 index 0200341..8653019 100644 --- a/Winget-AutoUpdate/functions/Get-Policies.ps1 +++ b/Winget-AutoUpdate/functions/Get-Policies.ps1 @@ -356,6 +356,15 @@ Function Get-Policies { $ChangedSettings++ } + if ($null -ne $($WAUPolicies.WAU_UserApproval) -and ($($WAUPolicies.WAU_UserApproval) -ne $($WAUConfig.WAU_UserApproval))) { + New-ItemProperty $regPath -Name WAU_UserApproval -Value $($WAUPolicies.WAU_UserApproval) -PropertyType DWord -Force | Out-Null + $ChangedSettings++ + } + elseif ($null -eq $($WAUPolicies.WAU_UserApproval) -and ($($WAUConfig.WAU_UserApproval) -or $($WAUConfig.WAU_UserApproval) -eq 0)) { + Remove-ItemProperty $regPath -Name WAU_UserApproval -Force -ErrorAction SilentlyContinue | Out-Null + $ChangedSettings++ + } + #Get WAU Configurations after Policies change $Script:WAUConfig = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" } From fdde423e7200340eea2a6d5d2f4edf7a04c3e6d1 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Fri, 28 Apr 2023 15:13:41 +0200 Subject: [PATCH 109/131] admx/adml updated --- Policies/WAU.admx | 5 +++-- Policies/en-US/WAU.adml | 3 ++- Winget-AutoUpdate/Winget-Upgrade.ps1 | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Policies/WAU.admx b/Policies/WAU.admx index db17dd5..3b3584c 100644 --- a/Policies/WAU.admx +++ b/Policies/WAU.admx @@ -1,5 +1,5 @@ - + @@ -8,6 +8,7 @@ + @@ -352,7 +353,7 @@ - + diff --git a/Policies/en-US/WAU.adml b/Policies/en-US/WAU.adml index 85d1a26..d221d35 100644 --- a/Policies/en-US/WAU.adml +++ b/Policies/en-US/WAU.adml @@ -1,5 +1,5 @@ - + WinGet-AutoUpdate WinGet-AutoUpdate GPO Management @@ -7,6 +7,7 @@ Winget-AutoUpdate Winget-AutoUpdate version 1.16.0 or later Winget-AutoUpdate version 1.16.5 or later + Winget-AutoUpdate version 1.17.0 or later Activate WAU GPO Management This policy setting is an overriding toggle for GPO Management of Winget-AutoUpdate. Bypass Black/White list for User diff --git a/Winget-AutoUpdate/Winget-Upgrade.ps1 b/Winget-AutoUpdate/Winget-Upgrade.ps1 index 461b7dc..0589799 100644 --- a/Winget-AutoUpdate/Winget-Upgrade.ps1 +++ b/Winget-AutoUpdate/Winget-Upgrade.ps1 @@ -243,7 +243,7 @@ if (Test-Network) { #Check for approved tag $WAUNotifApproved = "$WorkingDir/Config/NotifApproved.txt" if (Test-Path $WAUNotifApproved) { - Write-ToLog "-> User approved notification." + Write-ToLog "-> User approved update notification." Remove-Item $WAUNotifApproved -Force -Confirm:$false } else { From e9f38a6e334089a038e22302f5f21cf1a73e4f83 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Fri, 28 Apr 2023 18:40:10 +0200 Subject: [PATCH 110/131] admx from 1.8.0 --- Policies/WAU.admx | 4 ++-- Policies/en-US/WAU.adml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Policies/WAU.admx b/Policies/WAU.admx index 3b3584c..4b4937b 100644 --- a/Policies/WAU.admx +++ b/Policies/WAU.admx @@ -8,7 +8,7 @@ - + @@ -353,7 +353,7 @@ - + diff --git a/Policies/en-US/WAU.adml b/Policies/en-US/WAU.adml index d221d35..44a00b2 100644 --- a/Policies/en-US/WAU.adml +++ b/Policies/en-US/WAU.adml @@ -7,7 +7,7 @@ Winget-AutoUpdate Winget-AutoUpdate version 1.16.0 or later Winget-AutoUpdate version 1.16.5 or later - Winget-AutoUpdate version 1.17.0 or later + Winget-AutoUpdate version 1.18.0 or later Activate WAU GPO Management This policy setting is an overriding toggle for GPO Management of Winget-AutoUpdate. Bypass Black/White list for User From e37c2bab5d2e3c5b57621e8e3be9fb8323bcbb38 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Fri, 28 Apr 2023 18:41:12 +0200 Subject: [PATCH 111/131] 1.18.0 --- Policies/en-US/WAU.adml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Policies/en-US/WAU.adml b/Policies/en-US/WAU.adml index 44a00b2..35b310f 100644 --- a/Policies/en-US/WAU.adml +++ b/Policies/en-US/WAU.adml @@ -7,7 +7,7 @@ Winget-AutoUpdate Winget-AutoUpdate version 1.16.0 or later Winget-AutoUpdate version 1.16.5 or later - Winget-AutoUpdate version 1.18.0 or later + Winget-AutoUpdate version 1.18.0 or later Activate WAU GPO Management This policy setting is an overriding toggle for GPO Management of Winget-AutoUpdate. Bypass Black/White list for User From ee36c4c87c96d8ecf91364a2a8faf2d21b516d4c Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Fri, 28 Apr 2023 19:03:57 +0200 Subject: [PATCH 112/131] another 1.18.0 --- Policies/WAU.admx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Policies/WAU.admx b/Policies/WAU.admx index 4b4937b..7909507 100644 --- a/Policies/WAU.admx +++ b/Policies/WAU.admx @@ -8,7 +8,7 @@ - + From 7ab2bf11d5f9fefb63e902b56442b2f0fa1b0428 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Sat, 29 Apr 2023 23:26:36 +0200 Subject: [PATCH 113/131] wau --- Winget-AutoUpdate/functions/Invoke-UserApproval.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Winget-AutoUpdate/functions/Invoke-UserApproval.ps1 b/Winget-AutoUpdate/functions/Invoke-UserApproval.ps1 index 4b2f8c7..79ab72a 100644 --- a/Winget-AutoUpdate/functions/Invoke-UserApproval.ps1 +++ b/Winget-AutoUpdate/functions/Invoke-UserApproval.ps1 @@ -9,7 +9,7 @@ function Invoke-UserApproval ($outdated){ $WAUClassRun = "Wscript.exe ""$WorkingDir\Invisible.vbs"" ""powershell.exe -NoProfile -ExecutionPolicy Bypass -Command & '$WorkingDir\User-Run.ps1' -NotifApproved %1""" New-Item $WAUClassCmd -Force -ErrorAction SilentlyContinue | Out-Null New-ItemProperty -LiteralPath $WAUClass -Name 'URL Protocol' -Value '' -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null - New-ItemProperty -LiteralPath $WAUClass -Name '(default)' -Value "URL:$($ActionType)" -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null + New-ItemProperty -LiteralPath $WAUClass -Name '(default)' -Value "URL:WAU" -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null New-ItemProperty -LiteralPath $WAUClass -Name 'EditFlags' -Value '2162688' -PropertyType DWord -Force -ErrorAction SilentlyContinue | Out-Null New-ItemProperty -LiteralPath $WAUClassCmd -Name '(default)' -Value $WAUClassRun -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null $Button1Action = "wau:system" From 5ba779d17147193e941a7e7efe8404a5cb54518f Mon Sep 17 00:00:00 2001 From: Fabian Seitz Date: Tue, 2 May 2023 12:28:29 +0200 Subject: [PATCH 114/131] Symlink full WAU folder --- Winget-AutoUpdate/functions/Start-Init.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Winget-AutoUpdate/functions/Start-Init.ps1 b/Winget-AutoUpdate/functions/Start-Init.ps1 index e0b6a83..faf6b2c 100644 --- a/Winget-AutoUpdate/functions/Start-Init.ps1 +++ b/Winget-AutoUpdate/functions/Start-Init.ps1 @@ -44,9 +44,9 @@ function Start-Init { } #Check if Intune Management Extension Logs folder and WAU-updates.log exists, make symlink - if ((Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs") -and !(Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-updates.log")) { + if ((Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs") -and !(Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-Logs")) { Write-host "`nCreating SymLink for log file in Intune Management Extension log folder" -ForegroundColor Yellow - New-Item -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-updates.log" -ItemType SymbolicLink -Value $LogFile -Force -ErrorAction SilentlyContinue | Out-Null + New-Item -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-Logs" -ItemType SymbolicLink -Value "$WingetUpdatePath\logs" -Force -ErrorAction SilentlyContinue | Out-Null } From 463f11a9265af1968d2351fac4b6965f6a8088d6 Mon Sep 17 00:00:00 2001 From: Fabian Seitz Date: Tue, 2 May 2023 13:08:39 +0200 Subject: [PATCH 115/131] Create symlink for install.log --- Winget-AutoUpdate/functions/Start-Init.ps1 | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Winget-AutoUpdate/functions/Start-Init.ps1 b/Winget-AutoUpdate/functions/Start-Init.ps1 index faf6b2c..b3f0c87 100644 --- a/Winget-AutoUpdate/functions/Start-Init.ps1 +++ b/Winget-AutoUpdate/functions/Start-Init.ps1 @@ -44,12 +44,15 @@ function Start-Init { } #Check if Intune Management Extension Logs folder and WAU-updates.log exists, make symlink - if ((Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs") -and !(Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-Logs")) { - Write-host "`nCreating SymLink for log file in Intune Management Extension log folder" -ForegroundColor Yellow - New-Item -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-Logs" -ItemType SymbolicLink -Value "$WingetUpdatePath\logs" -Force -ErrorAction SilentlyContinue | Out-Null + if ((Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs") -and !(Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-updates.log")) { + Write-host "`nCreating SymLink for log file (WAU-updates) in Intune Management Extension log folder" -ForegroundColor Yellow + New-Item -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-updates.log" -ItemType SymbolicLink -Value $LogFile -Force -ErrorAction SilentlyContinue | Out-Null } - - + if ((Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs") -and !(Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-install.log")) { + Write-host "`nCreating SymLink for log file (WAU-install) in Intune Management Extension log folder" -ForegroundColor Yellow + New-Item -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-install.log" -ItemType SymbolicLink -Value "$WorkingDir\logs\install.log" -Force -ErrorAction SilentlyContinue | Out-Null + } + if ($caller -eq "Winget-Upgrade.ps1") { #Log file $Log | out-file -filepath $LogFile -Append From 39be9b2e609ce621978c9946bac35d47c9e0d360 Mon Sep 17 00:00:00 2001 From: Fabian Seitz Date: Wed, 3 May 2023 08:13:58 +0200 Subject: [PATCH 116/131] Handle WAU-install symlinks in Updates and Uninstallations #333 --- README.md | 103 +++++++++--------- Winget-AutoUpdate-Install.ps1 | 3 + Winget-AutoUpdate/WAU-Uninstall.ps1 | 8 ++ .../functions/Invoke-PostUpdateActions.ps1 | 5 + Winget-AutoUpdate/functions/Start-Init.ps1 | 5 +- 5 files changed, 71 insertions(+), 53 deletions(-) diff --git a/README.md b/README.md index aa7073e..c932e8c 100644 --- a/README.md +++ b/README.md @@ -29,8 +29,9 @@ By default, scripts and components will be placed in ProgramData location (insid From version 1.9.0 (on new installations) WAU runs everyday at 6AM. You can now configure the frequency with `-UpdatesInterval` option (Daily, BiDaily, Weekly, BiWeekly or Monthly). You can also add `-UpdatesAtLogon` parameter to run at user logon and keep this option activated like previous versions (recommanded). ### Log location -You can find logs in install location, in logs folder. +You can find logs in install location, in logs folder. If **Intune Management Extension** is installed, a **SymLink** (WAU-updates.log) is created under **C:\ProgramData\Microsoft\IntuneManagementExtension\Logs** +If you are deploying winget Apps with [Winget-Install](https://github.com/Romanitho/Winget-Install) a **SymLink** (WAU-install.log) is also created under **C:\ProgramData\Microsoft\IntuneManagementExtension\Logs** ### "Unknown" App version As explained in this [post](https://github.com/microsoft/winget-cli/issues/1255), Winget cannot detect the current version of some installed apps. We decided to skip managing these apps with WAU to avoid retries each time WAU runs: @@ -59,55 +60,55 @@ A new Auto-Update process has been released from version 1.5.0. By default, WAU To disable WAU AutoUpdate, run the `Winget-AutoUpdate-Install.ps1` with `-DisableWAUAutoUpdate` parameter. ## Uninstall WAU -Simply uninstall it from your programs: +Simply uninstall it from your programs: ![image](https://user-images.githubusercontent.com/96626929/170879336-ef034956-4778-41f0-b8fd-d307b77b70a9.png) ## GUI installation -[WiGui](https://github.com/Romanitho/Winget-Install-GUI/) can be used to install WAU even easier: +[WiGui](https://github.com/Romanitho/Winget-Install-GUI/) can be used to install WAU even easier: ## Advanced installation You can run the `Winget-AutoUpdate-Install.ps1` script with parameters : -**-Silent** +**-Silent** Install Winget-AutoUpdate and prerequisites silently. -**-MaxLogFiles** -Specify number of allowed log files. -Default is 3 out of 0-99: -Setting MaxLogFiles to 0 don't delete any old archived log files. +**-MaxLogFiles** +Specify number of allowed log files. +Default is 3 out of 0-99: +Setting MaxLogFiles to 0 don't delete any old archived log files. Setting it to 1 keeps the original one and just let it grow. -**-MaxLogSize** -Specify the size of the log file in bytes before rotating. +**-MaxLogSize** +Specify the size of the log file in bytes before rotating. Default is 1048576 = 1 MB (ca. 7500 lines) -**-WingetUpdatePath** +**-WingetUpdatePath** Specify Winget-AutoUpdate installation location. Default: `C:\ProgramData\Winget-AutoUpdate` (Recommended to leave default). -**-DoNotUpdate** +**-DoNotUpdate** Do not run Winget-AutoUpdate after installation. By default, Winget-AutoUpdate is run just after installation. -**-DisableWAUAutoUpdate** +**-DisableWAUAutoUpdate** Disable Winget-AutoUpdate update checking. By default, WAU auto updates if new version is available on Github. -**-UseWhiteList** +**-UseWhiteList** Use White List instead of Black List. This setting will not create the "excluded_apps.txt" but "included_apps.txt". -**-ListPath** -Get Black/White List from external Path (**URL/UNC/Local/GPO**) - download/copy to Winget-AutoUpdate installation location if external list is newer. -**PATH** must end with a Directory, not a File... +**-ListPath** +Get Black/White List from external Path (**URL/UNC/Local/GPO**) - download/copy to Winget-AutoUpdate installation location if external list is newer. +**PATH** must end with a Directory, not a File... ...if the external Path is an **URL** and the web host doesn't respond with a date/time header for the file (i.e **GitHub**) then the file is always downloaded! -If `-ListPath` is set to **GPO** the Black/White List can be managed from within the GPO itself under **Application GPO Blacklist**/**Application GPO Whitelist**. +If `-ListPath` is set to **GPO** the Black/White List can be managed from within the GPO itself under **Application GPO Blacklist**/**Application GPO Whitelist**. Thanks to [Weatherlights](https://github.com/Weatherlights) in [#256 (reply in thread)](https://github.com/Romanitho/Winget-AutoUpdate/discussions/256#discussioncomment-4710599)! -**-ModsPath** -Get Mods from external Path (**URL/UNC/Local/AzureBlob**) - download/copy to `mods` in Winget-AutoUpdate installation location if external mods are newer. +**-ModsPath** +Get Mods from external Path (**URL/UNC/Local/AzureBlob**) - download/copy to `mods` in Winget-AutoUpdate installation location if external mods are newer. -For **URL**: This requires a site directory with **Directory Listing Enabled** and no index page overriding the listing of files (or an index page with href listing of all the **Mods** to be downloaded): +For **URL**: This requires a site directory with **Directory Listing Enabled** and no index page overriding the listing of files (or an index page with href listing of all the **Mods** to be downloaded): ``` ``` -Validated on **IIS/Apache**. +Validated on **IIS/Apache**. -**Nota bene IIS** : +**Nota bene IIS** : - The extension **.ps1** must be added as **MIME Types** (text/powershell-script) otherwise it's displayed in the listing but can't be opened - Files with special characters in the filename can't be opened by default from an IIS server - config must be administrated: **Enable Allow double escaping** in '**Request Filtering**' @@ -127,37 +128,37 @@ For **AzureBlob**: This requires the parameter **-AzureBlobURL** to be set with **-AzureBlobURL** Used in conjunction with the **-ModsPath** parameter to provide the Azure Storage Blob URL with SAS token. The SAS token must, at a minimum, have 'Read' and 'List' permissions. It is recommended to set the permisions at the container level and rotate the SAS token on a regular basis. Ensure the container reflects the same structure as found under the initial `mods` folder. (From version 1.16.4). -**-InstallUserContext** +**-InstallUserContext** Install WAU with system and **user** context executions (From version 1.15.3). -**-BypassListForUsers** +**-BypassListForUsers** Bypass Black/White list when run in user context (From version 1.15.0). -**-NoClean** +**-NoClean** Keep critical files when installing/uninstalling. This setting will keep "excluded_apps.txt", "included_apps.txt", "mods" and "logs" as they were. -**-DesktopShortcut** +**-DesktopShortcut** Create a shortcut for user interaction on the Desktop to run task `Winget-AutoUpdate` (From version 1.15.0). -**-StartMenuShortcut** +**-StartMenuShortcut** Create shortcuts for user interaction in the Start Menu to run task `Winget-AutoUpdate`, open Logs and Web Help (From version 1.15.0). -**-NotificationLevel** +**-NotificationLevel** Specify the Notification level: Full (Default, displays all notification), SuccessOnly (Only displays notification for success) or None (Does not show any popup). -**-UpdatesAtLogon** +**-UpdatesAtLogon** Set WAU to run at user logon. -**-UpdatesInterval** +**-UpdatesInterval** Specify the update frequency: Daily (Default), BiDaily, Weekly, BiWeekly, Monthly or Never. Can be set to 'Never' in combination with '-UpdatesAtLogon' for instance. -**-UpdatesAtTime** +**-UpdatesAtTime** Specify the time of the update interval execution time. Default 6AM. (From version 1.15.0). -**-RunOnMetered** +**-RunOnMetered** Run WAU on metered connection. Default No. -**-Uninstall** +**-Uninstall** Remove scheduled tasks and scripts. ## Intune/SCCM use @@ -165,38 +166,38 @@ See https://github.com/Romanitho/Winget-AutoUpdate/discussions/88 ## Custom scripts (Mods feature) From version 1.8.0, the Mods feature allows you to run additional scripts when upgrading or installing an app. -Just put the scripts in question with the **AppID** followed by the `-preinstall`, `-upgrade`, `-install` or `-installed` suffix in the **mods** folder. -> Runs before upgrade/install: `AppID-preinstall.ps1` -> Runs during upgrade/install (before install check): `AppID-upgrade.ps1`/`AppID-install.ps1` -> Runs after upgrade/install has been confirmed: `AppID-installed.ps1` +Just put the scripts in question with the **AppID** followed by the `-preinstall`, `-upgrade`, `-install` or `-installed` suffix in the **mods** folder. +> Runs before upgrade/install: `AppID-preinstall.ps1` +> Runs during upgrade/install (before install check): `AppID-upgrade.ps1`/`AppID-install.ps1` +> Runs after upgrade/install has been confirmed: `AppID-installed.ps1` -The **-install** mod will be used for upgrades too if **-upgrade** doesn't exist (**WAU** first tries `& $Winget upgrade --id` and if the app isn't detected after that `& $Winget install --id` is tried). -`AppID-install.ps1` is recommended because it's used in **both** scenarios. +The **-install** mod will be used for upgrades too if **-upgrade** doesn't exist (**WAU** first tries `& $Winget upgrade --id` and if the app isn't detected after that `& $Winget install --id` is tried). +`AppID-install.ps1` is recommended because it's used in **both** scenarios. -> Example: +> Example: If you want to run a script that removes the shortcut from **%PUBLIC%\Desktop** (we don't want to fill the desktop with shortcuts our users can't delete) just after installing **Acrobat Reader DC** (32-bit), prepare a powershell script that removes the Public Desktop shortcut **Acrobat Reader DC.lnk** and name your script like this: `Adobe.Acrobat.Reader.32-bit-installed.ps1` and put it in the **mods** folder. -You can find more information on [Winget-Install Repo](https://github.com/Romanitho/Winget-Install#custom-mods), as it's a related feature. +You can find more information on [Winget-Install Repo](https://github.com/Romanitho/Winget-Install#custom-mods), as it's a related feature. Read more in the `README.md` under the directory **mods**. -Share your mods with the community: +Share your mods with the community: https://github.com/Romanitho/Winget-AutoUpdate/discussions/categories/mods ### Winget native parameters Another finess is the **AppID** followed by the `-override` suffix as a **text file** (.**txt**) that you can place under the **mods** folder. -> Example: +> Example: > **Canneverbe.CDBurnerXP-override.txt** with the content `ADDLOCAL=All REMOVE=Desktop_Shortcut /qn` -This will use the **content** of the text file as a native **winget --override** parameter when upgrading (as proposed by [JonNesovic](https://github.com/JonNesovic) in [Mod for --override argument #244](https://github.com/Romanitho/Winget-AutoUpdate/discussions/244#discussion-4637666)). +This will use the **content** of the text file as a native **winget --override** parameter when upgrading (as proposed by [JonNesovic](https://github.com/JonNesovic) in [Mod for --override argument #244](https://github.com/Romanitho/Winget-AutoUpdate/discussions/244#discussion-4637666)). ## GPO Management -In an enterprise environment it's crucial that different groups can have different settings in applications etc. or to implement other mandatory settings, i.e for security/management reasons. -**WAU** doesn't have any setting that can be changed except for when installing (or editing the registry/the task `Winget-AutoUpdate` as **Admin**). -With the use of **ADML/ADMX** files you can manage every **WAU** setting from within **GPO**. -They will be detected/evaluated during the next run of **WAU** (taking effect before any actions). -The **GPO ADMX/ADML** validated with: -[Windows 10 - Validate ADMX for Ingestion](https://developer.vmware.com/samples/7115/windows-10---validate-admx-for-ingestion) +In an enterprise environment it's crucial that different groups can have different settings in applications etc. or to implement other mandatory settings, i.e for security/management reasons. +**WAU** doesn't have any setting that can be changed except for when installing (or editing the registry/the task `Winget-AutoUpdate` as **Admin**). +With the use of **ADML/ADMX** files you can manage every **WAU** setting from within **GPO**. +They will be detected/evaluated during the next run of **WAU** (taking effect before any actions). +The **GPO ADMX/ADML** validated with: +[Windows 10 - Validate ADMX for Ingestion](https://developer.vmware.com/samples/7115/windows-10---validate-admx-for-ingestion) Read more in the `README.md` under the directory **Policies**. ![image](https://user-images.githubusercontent.com/102996177/213920242-7ff8e2b4-d926-4407-b860-1e5922e29c3e.png) diff --git a/Winget-AutoUpdate-Install.ps1 b/Winget-AutoUpdate-Install.ps1 index d72ce5a..45821e3 100644 --- a/Winget-AutoUpdate-Install.ps1 +++ b/Winget-AutoUpdate-Install.ps1 @@ -430,6 +430,9 @@ function Uninstall-WingetAutoUpdate { if (Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-updates.log") { Remove-Item -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-updates.log" -Force -ErrorAction SilentlyContinue | Out-Null } + if (Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-install.log") { + Remove-Item -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-install.log" -Force -ErrorAction SilentlyContinue | Out-Null + } } else { #Keep critical files diff --git a/Winget-AutoUpdate/WAU-Uninstall.ps1 b/Winget-AutoUpdate/WAU-Uninstall.ps1 index a90bda7..ff10d8d 100644 --- a/Winget-AutoUpdate/WAU-Uninstall.ps1 +++ b/Winget-AutoUpdate/WAU-Uninstall.ps1 @@ -64,6 +64,14 @@ try { Remove-Item -Path "${env:Public}\Desktop\WAU - Check for updated Apps.lnk" -Force | Out-Null } + #Remove Intune Logs if they are existing + if (Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-updates.log") { + Remove-Item -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-updates.log" -Force -ErrorAction SilentlyContinue | Out-Null + } + if (Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-install.log") { + Remove-Item -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-install.log" -Force -ErrorAction SilentlyContinue | Out-Null + } + Write-host "Uninstallation succeeded!" -ForegroundColor Green } else { diff --git a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 index ffd98bb..7bc4847 100644 --- a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 +++ b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 @@ -10,6 +10,11 @@ function Invoke-PostUpdateActions { Write-ToLog "-> Creating SymLink for log file in Intune Management Extension log folder" "yellow" New-Item -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-updates.log" -ItemType SymbolicLink -Value $LogFile -Force -ErrorAction SilentlyContinue | Out-Null } + #Check if Intune Management Extension Logs folder and WAU-install.log exists, make symlink + if ((Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs") -and (Test-Path "$WorkingDir\logs\install.log") -and !(Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-install.log")) { + Write-host "`nCreating SymLink for log file (WAU-install) in Intune Management Extension log folder" -ForegroundColor Yellow + New-Item -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-install.log" -ItemType SymbolicLink -Value "$WorkingDir\logs\install.log" -Force -ErrorAction SilentlyContinue | Out-Null + } Write-ToLog "-> Checking prerequisites..." "yellow" diff --git a/Winget-AutoUpdate/functions/Start-Init.ps1 b/Winget-AutoUpdate/functions/Start-Init.ps1 index b3f0c87..ac5d5c5 100644 --- a/Winget-AutoUpdate/functions/Start-Init.ps1 +++ b/Winget-AutoUpdate/functions/Start-Init.ps1 @@ -48,11 +48,12 @@ function Start-Init { Write-host "`nCreating SymLink for log file (WAU-updates) in Intune Management Extension log folder" -ForegroundColor Yellow New-Item -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-updates.log" -ItemType SymbolicLink -Value $LogFile -Force -ErrorAction SilentlyContinue | Out-Null } - if ((Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs") -and !(Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-install.log")) { + #Check if Intune Management Extension Logs folder and WAU-install.log exists, make symlink + if ((Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs") -and (Test-Path "$WorkingDir\logs\install.log") -and !(Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-install.log")) { Write-host "`nCreating SymLink for log file (WAU-install) in Intune Management Extension log folder" -ForegroundColor Yellow New-Item -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-install.log" -ItemType SymbolicLink -Value "$WorkingDir\logs\install.log" -Force -ErrorAction SilentlyContinue | Out-Null } - + if ($caller -eq "Winget-Upgrade.ps1") { #Log file $Log | out-file -filepath $LogFile -Append From 4703f4ee56812ae9a94950d87a704cdcc9a3ebec Mon Sep 17 00:00:00 2001 From: Fabian Seitz Date: Wed, 3 May 2023 10:55:32 +0200 Subject: [PATCH 117/131] restore whitespaces for linebreak --- README.md | 104 +++++++++++++++++++++++++++--------------------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/README.md b/README.md index c932e8c..06c5a20 100644 --- a/README.md +++ b/README.md @@ -29,8 +29,8 @@ By default, scripts and components will be placed in ProgramData location (insid From version 1.9.0 (on new installations) WAU runs everyday at 6AM. You can now configure the frequency with `-UpdatesInterval` option (Daily, BiDaily, Weekly, BiWeekly or Monthly). You can also add `-UpdatesAtLogon` parameter to run at user logon and keep this option activated like previous versions (recommanded). ### Log location -You can find logs in install location, in logs folder. -If **Intune Management Extension** is installed, a **SymLink** (WAU-updates.log) is created under **C:\ProgramData\Microsoft\IntuneManagementExtension\Logs** +You can find logs in install location, in logs folder. +If **Intune Management Extension** is installed, a **SymLink** (WAU-updates.log) is created under **C:\ProgramData\Microsoft\IntuneManagementExtension\Logs** If you are deploying winget Apps with [Winget-Install](https://github.com/Romanitho/Winget-Install) a **SymLink** (WAU-install.log) is also created under **C:\ProgramData\Microsoft\IntuneManagementExtension\Logs** ### "Unknown" App version @@ -60,55 +60,55 @@ A new Auto-Update process has been released from version 1.5.0. By default, WAU To disable WAU AutoUpdate, run the `Winget-AutoUpdate-Install.ps1` with `-DisableWAUAutoUpdate` parameter. ## Uninstall WAU -Simply uninstall it from your programs: +Simply uninstall it from your programs: ![image](https://user-images.githubusercontent.com/96626929/170879336-ef034956-4778-41f0-b8fd-d307b77b70a9.png) ## GUI installation -[WiGui](https://github.com/Romanitho/Winget-Install-GUI/) can be used to install WAU even easier: +[WiGui](https://github.com/Romanitho/Winget-Install-GUI/) can be used to install WAU even easier: ## Advanced installation You can run the `Winget-AutoUpdate-Install.ps1` script with parameters : -**-Silent** +**-Silent** Install Winget-AutoUpdate and prerequisites silently. -**-MaxLogFiles** -Specify number of allowed log files. -Default is 3 out of 0-99: -Setting MaxLogFiles to 0 don't delete any old archived log files. +**-MaxLogFiles** +Specify number of allowed log files. +Default is 3 out of 0-99: +Setting MaxLogFiles to 0 don't delete any old archived log files. Setting it to 1 keeps the original one and just let it grow. -**-MaxLogSize** -Specify the size of the log file in bytes before rotating. +**-MaxLogSize** +Specify the size of the log file in bytes before rotating. Default is 1048576 = 1 MB (ca. 7500 lines) -**-WingetUpdatePath** +**-WingetUpdatePath** Specify Winget-AutoUpdate installation location. Default: `C:\ProgramData\Winget-AutoUpdate` (Recommended to leave default). -**-DoNotUpdate** +**-DoNotUpdate** Do not run Winget-AutoUpdate after installation. By default, Winget-AutoUpdate is run just after installation. -**-DisableWAUAutoUpdate** +**-DisableWAUAutoUpdate** Disable Winget-AutoUpdate update checking. By default, WAU auto updates if new version is available on Github. -**-UseWhiteList** +**-UseWhiteList** Use White List instead of Black List. This setting will not create the "excluded_apps.txt" but "included_apps.txt". -**-ListPath** -Get Black/White List from external Path (**URL/UNC/Local/GPO**) - download/copy to Winget-AutoUpdate installation location if external list is newer. -**PATH** must end with a Directory, not a File... +**-ListPath** +Get Black/White List from external Path (**URL/UNC/Local/GPO**) - download/copy to Winget-AutoUpdate installation location if external list is newer. +**PATH** must end with a Directory, not a File... ...if the external Path is an **URL** and the web host doesn't respond with a date/time header for the file (i.e **GitHub**) then the file is always downloaded! -If `-ListPath` is set to **GPO** the Black/White List can be managed from within the GPO itself under **Application GPO Blacklist**/**Application GPO Whitelist**. +If `-ListPath` is set to **GPO** the Black/White List can be managed from within the GPO itself under **Application GPO Blacklist**/**Application GPO Whitelist**. Thanks to [Weatherlights](https://github.com/Weatherlights) in [#256 (reply in thread)](https://github.com/Romanitho/Winget-AutoUpdate/discussions/256#discussioncomment-4710599)! -**-ModsPath** -Get Mods from external Path (**URL/UNC/Local/AzureBlob**) - download/copy to `mods` in Winget-AutoUpdate installation location if external mods are newer. +**-ModsPath** +Get Mods from external Path (**URL/UNC/Local/AzureBlob**) - download/copy to `mods` in Winget-AutoUpdate installation location if external mods are newer. -For **URL**: This requires a site directory with **Directory Listing Enabled** and no index page overriding the listing of files (or an index page with href listing of all the **Mods** to be downloaded): +For **URL**: This requires a site directory with **Directory Listing Enabled** and no index page overriding the listing of files (or an index page with href listing of all the **Mods** to be downloaded): ``` ``` -Validated on **IIS/Apache**. +Validated on **IIS/Apache**. -**Nota bene IIS** : +**Nota bene IIS** : - The extension **.ps1** must be added as **MIME Types** (text/powershell-script) otherwise it's displayed in the listing but can't be opened - Files with special characters in the filename can't be opened by default from an IIS server - config must be administrated: **Enable Allow double escaping** in '**Request Filtering**' @@ -128,37 +128,37 @@ For **AzureBlob**: This requires the parameter **-AzureBlobURL** to be set with **-AzureBlobURL** Used in conjunction with the **-ModsPath** parameter to provide the Azure Storage Blob URL with SAS token. The SAS token must, at a minimum, have 'Read' and 'List' permissions. It is recommended to set the permisions at the container level and rotate the SAS token on a regular basis. Ensure the container reflects the same structure as found under the initial `mods` folder. (From version 1.16.4). -**-InstallUserContext** +**-InstallUserContext** Install WAU with system and **user** context executions (From version 1.15.3). -**-BypassListForUsers** +**-BypassListForUsers** Bypass Black/White list when run in user context (From version 1.15.0). -**-NoClean** +**-NoClean** Keep critical files when installing/uninstalling. This setting will keep "excluded_apps.txt", "included_apps.txt", "mods" and "logs" as they were. -**-DesktopShortcut** +**-DesktopShortcut** Create a shortcut for user interaction on the Desktop to run task `Winget-AutoUpdate` (From version 1.15.0). -**-StartMenuShortcut** +**-StartMenuShortcut** Create shortcuts for user interaction in the Start Menu to run task `Winget-AutoUpdate`, open Logs and Web Help (From version 1.15.0). -**-NotificationLevel** +**-NotificationLevel** Specify the Notification level: Full (Default, displays all notification), SuccessOnly (Only displays notification for success) or None (Does not show any popup). -**-UpdatesAtLogon** +**-UpdatesAtLogon** Set WAU to run at user logon. -**-UpdatesInterval** +**-UpdatesInterval** Specify the update frequency: Daily (Default), BiDaily, Weekly, BiWeekly, Monthly or Never. Can be set to 'Never' in combination with '-UpdatesAtLogon' for instance. -**-UpdatesAtTime** +**-UpdatesAtTime** Specify the time of the update interval execution time. Default 6AM. (From version 1.15.0). -**-RunOnMetered** +**-RunOnMetered** Run WAU on metered connection. Default No. -**-Uninstall** +**-Uninstall** Remove scheduled tasks and scripts. ## Intune/SCCM use @@ -166,38 +166,38 @@ See https://github.com/Romanitho/Winget-AutoUpdate/discussions/88 ## Custom scripts (Mods feature) From version 1.8.0, the Mods feature allows you to run additional scripts when upgrading or installing an app. -Just put the scripts in question with the **AppID** followed by the `-preinstall`, `-upgrade`, `-install` or `-installed` suffix in the **mods** folder. -> Runs before upgrade/install: `AppID-preinstall.ps1` -> Runs during upgrade/install (before install check): `AppID-upgrade.ps1`/`AppID-install.ps1` -> Runs after upgrade/install has been confirmed: `AppID-installed.ps1` +Just put the scripts in question with the **AppID** followed by the `-preinstall`, `-upgrade`, `-install` or `-installed` suffix in the **mods** folder. +> Runs before upgrade/install: `AppID-preinstall.ps1` +> Runs during upgrade/install (before install check): `AppID-upgrade.ps1`/`AppID-install.ps1` +> Runs after upgrade/install has been confirmed: `AppID-installed.ps1` -The **-install** mod will be used for upgrades too if **-upgrade** doesn't exist (**WAU** first tries `& $Winget upgrade --id` and if the app isn't detected after that `& $Winget install --id` is tried). -`AppID-install.ps1` is recommended because it's used in **both** scenarios. +The **-install** mod will be used for upgrades too if **-upgrade** doesn't exist (**WAU** first tries `& $Winget upgrade --id` and if the app isn't detected after that `& $Winget install --id` is tried). +`AppID-install.ps1` is recommended because it's used in **both** scenarios. -> Example: +> Example: If you want to run a script that removes the shortcut from **%PUBLIC%\Desktop** (we don't want to fill the desktop with shortcuts our users can't delete) just after installing **Acrobat Reader DC** (32-bit), prepare a powershell script that removes the Public Desktop shortcut **Acrobat Reader DC.lnk** and name your script like this: `Adobe.Acrobat.Reader.32-bit-installed.ps1` and put it in the **mods** folder. -You can find more information on [Winget-Install Repo](https://github.com/Romanitho/Winget-Install#custom-mods), as it's a related feature. +You can find more information on [Winget-Install Repo](https://github.com/Romanitho/Winget-Install#custom-mods), as it's a related feature. Read more in the `README.md` under the directory **mods**. -Share your mods with the community: +Share your mods with the community: https://github.com/Romanitho/Winget-AutoUpdate/discussions/categories/mods ### Winget native parameters Another finess is the **AppID** followed by the `-override` suffix as a **text file** (.**txt**) that you can place under the **mods** folder. -> Example: +> Example: > **Canneverbe.CDBurnerXP-override.txt** with the content `ADDLOCAL=All REMOVE=Desktop_Shortcut /qn` -This will use the **content** of the text file as a native **winget --override** parameter when upgrading (as proposed by [JonNesovic](https://github.com/JonNesovic) in [Mod for --override argument #244](https://github.com/Romanitho/Winget-AutoUpdate/discussions/244#discussion-4637666)). +This will use the **content** of the text file as a native **winget --override** parameter when upgrading (as proposed by [JonNesovic](https://github.com/JonNesovic) in [Mod for --override argument #244](https://github.com/Romanitho/Winget-AutoUpdate/discussions/244#discussion-4637666)). ## GPO Management -In an enterprise environment it's crucial that different groups can have different settings in applications etc. or to implement other mandatory settings, i.e for security/management reasons. -**WAU** doesn't have any setting that can be changed except for when installing (or editing the registry/the task `Winget-AutoUpdate` as **Admin**). -With the use of **ADML/ADMX** files you can manage every **WAU** setting from within **GPO**. -They will be detected/evaluated during the next run of **WAU** (taking effect before any actions). -The **GPO ADMX/ADML** validated with: -[Windows 10 - Validate ADMX for Ingestion](https://developer.vmware.com/samples/7115/windows-10---validate-admx-for-ingestion) +In an enterprise environment it's crucial that different groups can have different settings in applications etc. or to implement other mandatory settings, i.e for security/management reasons. +**WAU** doesn't have any setting that can be changed except for when installing (or editing the registry/the task `Winget-AutoUpdate` as **Admin**). +With the use of **ADML/ADMX** files you can manage every **WAU** setting from within **GPO**. +They will be detected/evaluated during the next run of **WAU** (taking effect before any actions). +The **GPO ADMX/ADML** validated with: +[Windows 10 - Validate ADMX for Ingestion](https://developer.vmware.com/samples/7115/windows-10---validate-admx-for-ingestion) Read more in the `README.md` under the directory **Policies**. ![image](https://user-images.githubusercontent.com/102996177/213920242-7ff8e2b4-d926-4407-b860-1e5922e29c3e.png) From e0513d31854b1846b98054801befe31d7d0adc99 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Wed, 3 May 2023 11:13:57 +0200 Subject: [PATCH 118/131] MCKanpolat/auto-semver-action@1.0.10 --- .github/workflows/WAU-AutoCreatePreVersion.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/WAU-AutoCreatePreVersion.yml b/.github/workflows/WAU-AutoCreatePreVersion.yml index 953e187..e0a10a0 100644 --- a/.github/workflows/WAU-AutoCreatePreVersion.yml +++ b/.github/workflows/WAU-AutoCreatePreVersion.yml @@ -53,7 +53,7 @@ jobs: fetch-depth: 0 - name: Auto Increment Semver Action - uses: MCKanpolat/auto-semver-action@1.0.9 + uses: MCKanpolat/auto-semver-action@1.0.10 id: versioning with: releaseType: prerelease From ffa4d62c7746115a61e1f6a22e48480f5ec432ba Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Wed, 3 May 2023 11:14:21 +0200 Subject: [PATCH 119/131] MCKanpolat/auto-semver-action@1.0.10 --- .github/workflows/WAU-CreateNewVersion.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/WAU-CreateNewVersion.yml b/.github/workflows/WAU-CreateNewVersion.yml index bf7dbd1..e510994 100644 --- a/.github/workflows/WAU-CreateNewVersion.yml +++ b/.github/workflows/WAU-CreateNewVersion.yml @@ -31,7 +31,7 @@ jobs: lfs: "true" - name: Auto Increment Semver Action - uses: MCKanpolat/auto-semver-action@1.0.9 + uses: MCKanpolat/auto-semver-action@1.0.10 id: versioning with: releaseType: ${{ github.event.inputs.version }} From 5ac0ce6a189fbf97b806f4afb5c433e9aed6c261 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 4 May 2023 00:31:28 +0000 Subject: [PATCH 120/131] Changed version to 1.17.5-0 --- Winget-AutoUpdate/Version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Winget-AutoUpdate/Version.txt b/Winget-AutoUpdate/Version.txt index 250f359..ceddc85 100644 --- a/Winget-AutoUpdate/Version.txt +++ b/Winget-AutoUpdate/Version.txt @@ -1 +1 @@ -1.17.4 \ No newline at end of file +1.17.5-0 \ No newline at end of file From 6a8bd5670ce302bd5d4c32bf8cc4fd9f3fac72c1 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Thu, 4 May 2023 10:09:48 +0200 Subject: [PATCH 121/131] Doc accuracy --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 06c5a20..57f585b 100644 --- a/README.md +++ b/README.md @@ -129,10 +129,10 @@ For **AzureBlob**: This requires the parameter **-AzureBlobURL** to be set with Used in conjunction with the **-ModsPath** parameter to provide the Azure Storage Blob URL with SAS token. The SAS token must, at a minimum, have 'Read' and 'List' permissions. It is recommended to set the permisions at the container level and rotate the SAS token on a regular basis. Ensure the container reflects the same structure as found under the initial `mods` folder. (From version 1.16.4). **-InstallUserContext** -Install WAU with system and **user** context executions (From version 1.15.3). +Install WAU with system and **user** context executions (From version 1.15.3). Applications installed in system context will be ignored under user context. **-BypassListForUsers** -Bypass Black/White list when run in user context (From version 1.15.0). +Bypass Black/White list when run in user context (From version 1.15.0). Also bypass system list (Allowing failing apps to retry under user context. Admin right might be required). **-NoClean** Keep critical files when installing/uninstalling. This setting will keep "excluded_apps.txt", "included_apps.txt", "mods" and "logs" as they were. From 18c7f8c61eb024f42c5ecb8fc4cd2a93034addeb Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Thu, 4 May 2023 10:42:42 +0200 Subject: [PATCH 122/131] Bug fix + doc --- README.md | 106 +++++++++++++-------------- Winget-AutoUpdate-Install.ps1 | 2 +- Winget-AutoUpdate/Winget-Upgrade.ps1 | 2 +- 3 files changed, 55 insertions(+), 55 deletions(-) diff --git a/README.md b/README.md index 57f585b..3bf8a2f 100644 --- a/README.md +++ b/README.md @@ -29,8 +29,8 @@ By default, scripts and components will be placed in ProgramData location (insid From version 1.9.0 (on new installations) WAU runs everyday at 6AM. You can now configure the frequency with `-UpdatesInterval` option (Daily, BiDaily, Weekly, BiWeekly or Monthly). You can also add `-UpdatesAtLogon` parameter to run at user logon and keep this option activated like previous versions (recommanded). ### Log location -You can find logs in install location, in logs folder. -If **Intune Management Extension** is installed, a **SymLink** (WAU-updates.log) is created under **C:\ProgramData\Microsoft\IntuneManagementExtension\Logs** +You can find logs in install location, in logs folder. +If **Intune Management Extension** is installed, a **SymLink** (WAU-updates.log) is created under **C:\ProgramData\Microsoft\IntuneManagementExtension\Logs** If you are deploying winget Apps with [Winget-Install](https://github.com/Romanitho/Winget-Install) a **SymLink** (WAU-install.log) is also created under **C:\ProgramData\Microsoft\IntuneManagementExtension\Logs** ### "Unknown" App version @@ -60,55 +60,55 @@ A new Auto-Update process has been released from version 1.5.0. By default, WAU To disable WAU AutoUpdate, run the `Winget-AutoUpdate-Install.ps1` with `-DisableWAUAutoUpdate` parameter. ## Uninstall WAU -Simply uninstall it from your programs: +Simply uninstall it from your programs: ![image](https://user-images.githubusercontent.com/96626929/170879336-ef034956-4778-41f0-b8fd-d307b77b70a9.png) ## GUI installation -[WiGui](https://github.com/Romanitho/Winget-Install-GUI/) can be used to install WAU even easier: +[WiGui](https://github.com/Romanitho/Winget-Install-GUI/) can be used to install WAU even easier: ## Advanced installation You can run the `Winget-AutoUpdate-Install.ps1` script with parameters : -**-Silent** +**-Silent** Install Winget-AutoUpdate and prerequisites silently. -**-MaxLogFiles** -Specify number of allowed log files. -Default is 3 out of 0-99: -Setting MaxLogFiles to 0 don't delete any old archived log files. +**-MaxLogFiles** +Specify number of allowed log files. +Default is 3 out of 0-99: +Setting MaxLogFiles to 0 don't delete any old archived log files. Setting it to 1 keeps the original one and just let it grow. -**-MaxLogSize** -Specify the size of the log file in bytes before rotating. +**-MaxLogSize** +Specify the size of the log file in bytes before rotating. Default is 1048576 = 1 MB (ca. 7500 lines) -**-WingetUpdatePath** +**-WingetUpdatePath** Specify Winget-AutoUpdate installation location. Default: `C:\ProgramData\Winget-AutoUpdate` (Recommended to leave default). -**-DoNotUpdate** +**-DoNotUpdate** Do not run Winget-AutoUpdate after installation. By default, Winget-AutoUpdate is run just after installation. -**-DisableWAUAutoUpdate** +**-DisableWAUAutoUpdate** Disable Winget-AutoUpdate update checking. By default, WAU auto updates if new version is available on Github. -**-UseWhiteList** +**-UseWhiteList** Use White List instead of Black List. This setting will not create the "excluded_apps.txt" but "included_apps.txt". -**-ListPath** -Get Black/White List from external Path (**URL/UNC/Local/GPO**) - download/copy to Winget-AutoUpdate installation location if external list is newer. -**PATH** must end with a Directory, not a File... +**-ListPath** +Get Black/White List from external Path (**URL/UNC/Local/GPO**) - download/copy to Winget-AutoUpdate installation location if external list is newer. +**PATH** must end with a Directory, not a File... ...if the external Path is an **URL** and the web host doesn't respond with a date/time header for the file (i.e **GitHub**) then the file is always downloaded! -If `-ListPath` is set to **GPO** the Black/White List can be managed from within the GPO itself under **Application GPO Blacklist**/**Application GPO Whitelist**. +If `-ListPath` is set to **GPO** the Black/White List can be managed from within the GPO itself under **Application GPO Blacklist**/**Application GPO Whitelist**. Thanks to [Weatherlights](https://github.com/Weatherlights) in [#256 (reply in thread)](https://github.com/Romanitho/Winget-AutoUpdate/discussions/256#discussioncomment-4710599)! -**-ModsPath** -Get Mods from external Path (**URL/UNC/Local/AzureBlob**) - download/copy to `mods` in Winget-AutoUpdate installation location if external mods are newer. +**-ModsPath** +Get Mods from external Path (**URL/UNC/Local/AzureBlob**) - download/copy to `mods` in Winget-AutoUpdate installation location if external mods are newer. -For **URL**: This requires a site directory with **Directory Listing Enabled** and no index page overriding the listing of files (or an index page with href listing of all the **Mods** to be downloaded): +For **URL**: This requires a site directory with **Directory Listing Enabled** and no index page overriding the listing of files (or an index page with href listing of all the **Mods** to be downloaded): ``` ``` -Validated on **IIS/Apache**. +Validated on **IIS/Apache**. -**Nota bene IIS** : +**Nota bene IIS** : - The extension **.ps1** must be added as **MIME Types** (text/powershell-script) otherwise it's displayed in the listing but can't be opened - Files with special characters in the filename can't be opened by default from an IIS server - config must be administrated: **Enable Allow double escaping** in '**Request Filtering**' @@ -128,37 +128,37 @@ For **AzureBlob**: This requires the parameter **-AzureBlobURL** to be set with **-AzureBlobURL** Used in conjunction with the **-ModsPath** parameter to provide the Azure Storage Blob URL with SAS token. The SAS token must, at a minimum, have 'Read' and 'List' permissions. It is recommended to set the permisions at the container level and rotate the SAS token on a regular basis. Ensure the container reflects the same structure as found under the initial `mods` folder. (From version 1.16.4). -**-InstallUserContext** +**-InstallUserContext** Install WAU with system and **user** context executions (From version 1.15.3). Applications installed in system context will be ignored under user context. -**-BypassListForUsers** -Bypass Black/White list when run in user context (From version 1.15.0). Also bypass system list (Allowing failing apps to retry under user context. Admin right might be required). +**-BypassListForUsers** +Bypass Black/White list when run in user context (From version 1.15.0). -**-NoClean** +**-NoClean** Keep critical files when installing/uninstalling. This setting will keep "excluded_apps.txt", "included_apps.txt", "mods" and "logs" as they were. -**-DesktopShortcut** +**-DesktopShortcut** Create a shortcut for user interaction on the Desktop to run task `Winget-AutoUpdate` (From version 1.15.0). -**-StartMenuShortcut** +**-StartMenuShortcut** Create shortcuts for user interaction in the Start Menu to run task `Winget-AutoUpdate`, open Logs and Web Help (From version 1.15.0). -**-NotificationLevel** +**-NotificationLevel** Specify the Notification level: Full (Default, displays all notification), SuccessOnly (Only displays notification for success) or None (Does not show any popup). -**-UpdatesAtLogon** +**-UpdatesAtLogon** Set WAU to run at user logon. -**-UpdatesInterval** +**-UpdatesInterval** Specify the update frequency: Daily (Default), BiDaily, Weekly, BiWeekly, Monthly or Never. Can be set to 'Never' in combination with '-UpdatesAtLogon' for instance. -**-UpdatesAtTime** +**-UpdatesAtTime** Specify the time of the update interval execution time. Default 6AM. (From version 1.15.0). -**-RunOnMetered** +**-RunOnMetered** Run WAU on metered connection. Default No. -**-Uninstall** +**-Uninstall** Remove scheduled tasks and scripts. ## Intune/SCCM use @@ -166,38 +166,38 @@ See https://github.com/Romanitho/Winget-AutoUpdate/discussions/88 ## Custom scripts (Mods feature) From version 1.8.0, the Mods feature allows you to run additional scripts when upgrading or installing an app. -Just put the scripts in question with the **AppID** followed by the `-preinstall`, `-upgrade`, `-install` or `-installed` suffix in the **mods** folder. -> Runs before upgrade/install: `AppID-preinstall.ps1` -> Runs during upgrade/install (before install check): `AppID-upgrade.ps1`/`AppID-install.ps1` -> Runs after upgrade/install has been confirmed: `AppID-installed.ps1` +Just put the scripts in question with the **AppID** followed by the `-preinstall`, `-upgrade`, `-install` or `-installed` suffix in the **mods** folder. +> Runs before upgrade/install: `AppID-preinstall.ps1` +> Runs during upgrade/install (before install check): `AppID-upgrade.ps1`/`AppID-install.ps1` +> Runs after upgrade/install has been confirmed: `AppID-installed.ps1` -The **-install** mod will be used for upgrades too if **-upgrade** doesn't exist (**WAU** first tries `& $Winget upgrade --id` and if the app isn't detected after that `& $Winget install --id` is tried). -`AppID-install.ps1` is recommended because it's used in **both** scenarios. +The **-install** mod will be used for upgrades too if **-upgrade** doesn't exist (**WAU** first tries `& $Winget upgrade --id` and if the app isn't detected after that `& $Winget install --id` is tried). +`AppID-install.ps1` is recommended because it's used in **both** scenarios. -> Example: +> Example: If you want to run a script that removes the shortcut from **%PUBLIC%\Desktop** (we don't want to fill the desktop with shortcuts our users can't delete) just after installing **Acrobat Reader DC** (32-bit), prepare a powershell script that removes the Public Desktop shortcut **Acrobat Reader DC.lnk** and name your script like this: `Adobe.Acrobat.Reader.32-bit-installed.ps1` and put it in the **mods** folder. -You can find more information on [Winget-Install Repo](https://github.com/Romanitho/Winget-Install#custom-mods), as it's a related feature. +You can find more information on [Winget-Install Repo](https://github.com/Romanitho/Winget-Install#custom-mods), as it's a related feature. Read more in the `README.md` under the directory **mods**. -Share your mods with the community: +Share your mods with the community: https://github.com/Romanitho/Winget-AutoUpdate/discussions/categories/mods ### Winget native parameters Another finess is the **AppID** followed by the `-override` suffix as a **text file** (.**txt**) that you can place under the **mods** folder. -> Example: +> Example: > **Canneverbe.CDBurnerXP-override.txt** with the content `ADDLOCAL=All REMOVE=Desktop_Shortcut /qn` -This will use the **content** of the text file as a native **winget --override** parameter when upgrading (as proposed by [JonNesovic](https://github.com/JonNesovic) in [Mod for --override argument #244](https://github.com/Romanitho/Winget-AutoUpdate/discussions/244#discussion-4637666)). +This will use the **content** of the text file as a native **winget --override** parameter when upgrading (as proposed by [JonNesovic](https://github.com/JonNesovic) in [Mod for --override argument #244](https://github.com/Romanitho/Winget-AutoUpdate/discussions/244#discussion-4637666)). ## GPO Management -In an enterprise environment it's crucial that different groups can have different settings in applications etc. or to implement other mandatory settings, i.e for security/management reasons. -**WAU** doesn't have any setting that can be changed except for when installing (or editing the registry/the task `Winget-AutoUpdate` as **Admin**). -With the use of **ADML/ADMX** files you can manage every **WAU** setting from within **GPO**. -They will be detected/evaluated during the next run of **WAU** (taking effect before any actions). -The **GPO ADMX/ADML** validated with: -[Windows 10 - Validate ADMX for Ingestion](https://developer.vmware.com/samples/7115/windows-10---validate-admx-for-ingestion) +In an enterprise environment it's crucial that different groups can have different settings in applications etc. or to implement other mandatory settings, i.e for security/management reasons. +**WAU** doesn't have any setting that can be changed except for when installing (or editing the registry/the task `Winget-AutoUpdate` as **Admin**). +With the use of **ADML/ADMX** files you can manage every **WAU** setting from within **GPO**. +They will be detected/evaluated during the next run of **WAU** (taking effect before any actions). +The **GPO ADMX/ADML** validated with: +[Windows 10 - Validate ADMX for Ingestion](https://developer.vmware.com/samples/7115/windows-10---validate-admx-for-ingestion) Read more in the `README.md` under the directory **Policies**. ![image](https://user-images.githubusercontent.com/102996177/213920242-7ff8e2b4-d926-4407-b860-1e5922e29c3e.png) diff --git a/Winget-AutoUpdate-Install.ps1 b/Winget-AutoUpdate-Install.ps1 index 45821e3..3f7b02e 100644 --- a/Winget-AutoUpdate-Install.ps1 +++ b/Winget-AutoUpdate-Install.ps1 @@ -68,7 +68,7 @@ Run WAU on metered connection. Default No. Install WAU with system and user context executions .PARAMETER BypassListForUsers -Configure WAU to bypass the Black/White list when run in user context +Configure WAU to bypass the Black/White list when run in user context. Applications installed in system context will be ignored under user context. .EXAMPLE .\Winget-AutoUpdate-Install.ps1 -Silent -DoNotUpdate -MaxLogFiles 4 -MaxLogSize 2097152 diff --git a/Winget-AutoUpdate/Winget-Upgrade.ps1 b/Winget-AutoUpdate/Winget-Upgrade.ps1 index 3b2e8e0..9524a79 100644 --- a/Winget-AutoUpdate/Winget-Upgrade.ps1 +++ b/Winget-AutoUpdate/Winget-Upgrade.ps1 @@ -240,7 +240,7 @@ if (Test-Network) { $Script:InstallOK = 0 #Trick under user context when -BypassListForUsers is used - if ($IsSystem -eq $false -and $WAUConfig.WAU_BypassListForUsers -eq $true) { + if ($IsSystem -eq $false -and $WAUConfig.WAU_BypassListForUsers -eq 1) { Write-ToLog "Bypass system list in user context is Enabled." $UseWhiteList = $false $toSkip = $null From 7c4d04b25b2bc750fa963c89cacbba2be3bed401 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Thu, 4 May 2023 10:57:10 +0200 Subject: [PATCH 123/131] Cleanning --- README.md | 70 +++++++++++++++++++++++++++---------------------------- 1 file changed, 34 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 3bf8a2f..b6db064 100644 --- a/README.md +++ b/README.md @@ -72,32 +72,32 @@ Simply uninstall it from your programs: ## Advanced installation You can run the `Winget-AutoUpdate-Install.ps1` script with parameters : -**-Silent** +**-Silent**
      Install Winget-AutoUpdate and prerequisites silently. -**-MaxLogFiles** +**-MaxLogFiles**
      Specify number of allowed log files. Default is 3 out of 0-99: Setting MaxLogFiles to 0 don't delete any old archived log files. Setting it to 1 keeps the original one and just let it grow. -**-MaxLogSize** +**-MaxLogSize**
      Specify the size of the log file in bytes before rotating. Default is 1048576 = 1 MB (ca. 7500 lines) -**-WingetUpdatePath** +**-WingetUpdatePath**
      Specify Winget-AutoUpdate installation location. Default: `C:\ProgramData\Winget-AutoUpdate` (Recommended to leave default). -**-DoNotUpdate** +**-DoNotUpdate**
      Do not run Winget-AutoUpdate after installation. By default, Winget-AutoUpdate is run just after installation. -**-DisableWAUAutoUpdate** +**-DisableWAUAutoUpdate**
      Disable Winget-AutoUpdate update checking. By default, WAU auto updates if new version is available on Github. -**-UseWhiteList** +**-UseWhiteList**
      Use White List instead of Black List. This setting will not create the "excluded_apps.txt" but "included_apps.txt". -**-ListPath** +**-ListPath**
      Get Black/White List from external Path (**URL/UNC/Local/GPO**) - download/copy to Winget-AutoUpdate installation location if external list is newer. **PATH** must end with a Directory, not a File... ...if the external Path is an **URL** and the web host doesn't respond with a date/time header for the file (i.e **GitHub**) then the file is always downloaded! @@ -105,7 +105,7 @@ Get Black/White List from external Path (**URL/UNC/Local/GPO**) - download/copy If `-ListPath` is set to **GPO** the Black/White List can be managed from within the GPO itself under **Application GPO Blacklist**/**Application GPO Whitelist**. Thanks to [Weatherlights](https://github.com/Weatherlights) in [#256 (reply in thread)](https://github.com/Romanitho/Winget-AutoUpdate/discussions/256#discussioncomment-4710599)! -**-ModsPath** +**-ModsPath**
      Get Mods from external Path (**URL/UNC/Local/AzureBlob**) - download/copy to `mods` in Winget-AutoUpdate installation location if external mods are newer. For **URL**: This requires a site directory with **Directory Listing Enabled** and no index page overriding the listing of files (or an index page with href listing of all the **Mods** to be downloaded): @@ -125,40 +125,40 @@ Validated on **IIS/Apache**. For **AzureBlob**: This requires the parameter **-AzureBlobURL** to be set with an appropriate Azure Blob Storage URL including the SAS token. See **-AzureBlobURL** for more information. -**-AzureBlobURL** +**-AzureBlobURL**
      Used in conjunction with the **-ModsPath** parameter to provide the Azure Storage Blob URL with SAS token. The SAS token must, at a minimum, have 'Read' and 'List' permissions. It is recommended to set the permisions at the container level and rotate the SAS token on a regular basis. Ensure the container reflects the same structure as found under the initial `mods` folder. (From version 1.16.4). -**-InstallUserContext** +**-InstallUserContext**
      Install WAU with system and **user** context executions (From version 1.15.3). Applications installed in system context will be ignored under user context. -**-BypassListForUsers** +**-BypassListForUsers**
      Bypass Black/White list when run in user context (From version 1.15.0). -**-NoClean** +**-NoClean**
      Keep critical files when installing/uninstalling. This setting will keep "excluded_apps.txt", "included_apps.txt", "mods" and "logs" as they were. -**-DesktopShortcut** +**-DesktopShortcut**
      Create a shortcut for user interaction on the Desktop to run task `Winget-AutoUpdate` (From version 1.15.0). -**-StartMenuShortcut** +**-StartMenuShortcut**
      Create shortcuts for user interaction in the Start Menu to run task `Winget-AutoUpdate`, open Logs and Web Help (From version 1.15.0). -**-NotificationLevel** +**-NotificationLevel**
      Specify the Notification level: Full (Default, displays all notification), SuccessOnly (Only displays notification for success) or None (Does not show any popup). -**-UpdatesAtLogon** +**-UpdatesAtLogon**
      Set WAU to run at user logon. -**-UpdatesInterval** +**-UpdatesInterval**
      Specify the update frequency: Daily (Default), BiDaily, Weekly, BiWeekly, Monthly or Never. Can be set to 'Never' in combination with '-UpdatesAtLogon' for instance. -**-UpdatesAtTime** +**-UpdatesAtTime**
      Specify the time of the update interval execution time. Default 6AM. (From version 1.15.0). -**-RunOnMetered** +**-RunOnMetered**
      Run WAU on metered connection. Default No. -**-Uninstall** +**-Uninstall**
      Remove scheduled tasks and scripts. ## Intune/SCCM use @@ -171,33 +171,31 @@ Just put the scripts in question with the **AppID** followed by the `-preinstall > Runs during upgrade/install (before install check): `AppID-upgrade.ps1`/`AppID-install.ps1` > Runs after upgrade/install has been confirmed: `AppID-installed.ps1` -The **-install** mod will be used for upgrades too if **-upgrade** doesn't exist (**WAU** first tries `& $Winget upgrade --id` and if the app isn't detected after that `& $Winget install --id` is tried). +The **-install** mod will be used for upgrades too if **-upgrade** doesn't exist (**WAU** first tries `& $Winget upgrade --id` and if the app isn't detected after that `& $Winget install --id` is tried).
      `AppID-install.ps1` is recommended because it's used in **both** scenarios. -> Example: -If you want to run a script that removes the shortcut from **%PUBLIC%\Desktop** (we don't want to fill the desktop with shortcuts our users can't delete) just after installing **Acrobat Reader DC** (32-bit), prepare a powershell script that removes the Public Desktop shortcut **Acrobat Reader DC.lnk** and name your script like this: -`Adobe.Acrobat.Reader.32-bit-installed.ps1` and put it in the **mods** folder. +> Example:
      +> If you want to run a script that removes the shortcut from **%PUBLIC%\Desktop** (we don't want to fill the desktop with shortcuts our users can't delete) just after installing **Acrobat Reader DC** (32-bit), prepare a powershell script that removes the Public Desktop shortcut **Acrobat Reader DC.lnk** and name your script like this: `Adobe.Acrobat.Reader.32-bit-installed.ps1` and put it in the **mods** folder. -You can find more information on [Winget-Install Repo](https://github.com/Romanitho/Winget-Install#custom-mods), as it's a related feature. +You can find more information on [Winget-Install Repo](https://github.com/Romanitho/Winget-Install#custom-mods), as it's a related feature.
      Read more in the `README.md` under the directory **mods**. -Share your mods with the community: +Share your mods with the community:
      https://github.com/Romanitho/Winget-AutoUpdate/discussions/categories/mods ### Winget native parameters Another finess is the **AppID** followed by the `-override` suffix as a **text file** (.**txt**) that you can place under the **mods** folder. -> Example: -> **Canneverbe.CDBurnerXP-override.txt** with the content `ADDLOCAL=All REMOVE=Desktop_Shortcut /qn` +> Example:
      +> **Canneverbe.CDBurnerXP-override.txt** with the content `ADDLOCAL=All REMOVE=Desktop_Shortcut /qn` This will use the **content** of the text file as a native **winget --override** parameter when upgrading (as proposed by [JonNesovic](https://github.com/JonNesovic) in [Mod for --override argument #244](https://github.com/Romanitho/Winget-AutoUpdate/discussions/244#discussion-4637666)). ## GPO Management -In an enterprise environment it's crucial that different groups can have different settings in applications etc. or to implement other mandatory settings, i.e for security/management reasons. -**WAU** doesn't have any setting that can be changed except for when installing (or editing the registry/the task `Winget-AutoUpdate` as **Admin**). -With the use of **ADML/ADMX** files you can manage every **WAU** setting from within **GPO**. -They will be detected/evaluated during the next run of **WAU** (taking effect before any actions). -The **GPO ADMX/ADML** validated with: -[Windows 10 - Validate ADMX for Ingestion](https://developer.vmware.com/samples/7115/windows-10---validate-admx-for-ingestion) +In an enterprise environment it's crucial that different groups can have different settings in applications etc. or to implement other mandatory settings, i.e for security/management reasons.
      +**WAU** doesn't have any setting that can be changed except for when installing (or editing the registry/the task `Winget-AutoUpdate` as **Admin**).
      +With the use of **ADML/ADMX** files you can manage every **WAU** setting from within **GPO**.
      +They will be detected/evaluated during the next run of **WAU** (taking effect before any actions).
      +The **GPO ADMX/ADML** validated with: [Windows 10 - Validate ADMX for Ingestion](https://developer.vmware.com/samples/7115/windows-10---validate-admx-for-ingestion)
      Read more in the `README.md` under the directory **Policies**. ![image](https://user-images.githubusercontent.com/102996177/213920242-7ff8e2b4-d926-4407-b860-1e5922e29c3e.png) @@ -209,4 +207,4 @@ In some cases, you need to "unblock" the `install.bat` file (Windows Defender Sm * As reported by [soredake](https://github.com/soredake), Powershell from MsStore is not supported with WAU in system context. See https://github.com/Romanitho/Winget-AutoUpdate/issues/113 ## Optimization -Feel free to give us any suggestions or optimizations in code and support us by adding a star :). +Feel free to give us any suggestions or optimizations in code and support us by adding a star :) From 44787a59d48b74f703f9d208e992827994ca7932 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Thu, 4 May 2023 11:02:56 +0200 Subject: [PATCH 124/131]
      --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b6db064..0f8f846 100644 --- a/README.md +++ b/README.md @@ -29,8 +29,8 @@ By default, scripts and components will be placed in ProgramData location (insid From version 1.9.0 (on new installations) WAU runs everyday at 6AM. You can now configure the frequency with `-UpdatesInterval` option (Daily, BiDaily, Weekly, BiWeekly or Monthly). You can also add `-UpdatesAtLogon` parameter to run at user logon and keep this option activated like previous versions (recommanded). ### Log location -You can find logs in install location, in logs folder. -If **Intune Management Extension** is installed, a **SymLink** (WAU-updates.log) is created under **C:\ProgramData\Microsoft\IntuneManagementExtension\Logs** +You can find logs in install location, in logs folder.
      +If **Intune Management Extension** is installed, a **SymLink** (WAU-updates.log) is created under **C:\ProgramData\Microsoft\IntuneManagementExtension\Logs**
      If you are deploying winget Apps with [Winget-Install](https://github.com/Romanitho/Winget-Install) a **SymLink** (WAU-install.log) is also created under **C:\ProgramData\Microsoft\IntuneManagementExtension\Logs** ### "Unknown" App version From 796a5f77f953524f71861a75fd39ae23bc7d64ba Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Thu, 4 May 2023 11:10:53 +0200 Subject: [PATCH 125/131] last review --- README.md | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 0f8f846..e1eb6ee 100644 --- a/README.md +++ b/README.md @@ -76,13 +76,13 @@ You can run the `Winget-AutoUpdate-Install.ps1` script with parameters : Install Winget-AutoUpdate and prerequisites silently. **-MaxLogFiles**
      -Specify number of allowed log files. -Default is 3 out of 0-99: -Setting MaxLogFiles to 0 don't delete any old archived log files. +Specify number of allowed log files.
      +Default is 3 out of 0-99:
      +Setting MaxLogFiles to 0 don't delete any old archived log files.
      Setting it to 1 keeps the original one and just let it grow. **-MaxLogSize**
      -Specify the size of the log file in bytes before rotating. +Specify the size of the log file in bytes before rotating.
      Default is 1048576 = 1 MB (ca. 7500 lines) **-WingetUpdatePath**
      @@ -98,16 +98,14 @@ Disable Winget-AutoUpdate update checking. By default, WAU auto updates if new v Use White List instead of Black List. This setting will not create the "excluded_apps.txt" but "included_apps.txt". **-ListPath**
      -Get Black/White List from external Path (**URL/UNC/Local/GPO**) - download/copy to Winget-AutoUpdate installation location if external list is newer. -**PATH** must end with a Directory, not a File... +Get Black/White List from external Path (**URL/UNC/Local/GPO**) - download/copy to Winget-AutoUpdate installation location if external list is newer.
      +**PATH** must end with a Directory, not a File...
      ...if the external Path is an **URL** and the web host doesn't respond with a date/time header for the file (i.e **GitHub**) then the file is always downloaded! - -If `-ListPath` is set to **GPO** the Black/White List can be managed from within the GPO itself under **Application GPO Blacklist**/**Application GPO Whitelist**. +If `-ListPath` is set to **GPO** the Black/White List can be managed from within the GPO itself under **Application GPO Blacklist**/**Application GPO Whitelist**.
      Thanks to [Weatherlights](https://github.com/Weatherlights) in [#256 (reply in thread)](https://github.com/Romanitho/Winget-AutoUpdate/discussions/256#discussioncomment-4710599)! **-ModsPath**
      -Get Mods from external Path (**URL/UNC/Local/AzureBlob**) - download/copy to `mods` in Winget-AutoUpdate installation location if external mods are newer. - +Get Mods from external Path (**URL/UNC/Local/AzureBlob**) - download/copy to `mods` in Winget-AutoUpdate installation location if external mods are newer.
      For **URL**: This requires a site directory with **Directory Listing Enabled** and no index page overriding the listing of files (or an index page with href listing of all the **Mods** to be downloaded): ``` ``` -Validated on **IIS/Apache**. - -**Nota bene IIS** : - - The extension **.ps1** must be added as **MIME Types** (text/powershell-script) otherwise it's displayed in the listing but can't be opened - - Files with special characters in the filename can't be opened by default from an IIS server - config must be administrated: **Enable Allow double escaping** in '**Request Filtering**' +Validated on **IIS/Apache**.
      +**Nota bene IIS** :
      +- The extension **.ps1** must be added as **MIME Types** (text/powershell-script) otherwise it's displayed in the listing but can't be opened +- Files with special characters in the filename can't be opened by default from an IIS server - config must be administrated: **Enable Allow double escaping** in '**Request Filtering**' For **AzureBlob**: This requires the parameter **-AzureBlobURL** to be set with an appropriate Azure Blob Storage URL including the SAS token. See **-AzureBlobURL** for more information. @@ -167,15 +164,16 @@ See https://github.com/Romanitho/Winget-AutoUpdate/discussions/88 ## Custom scripts (Mods feature) From version 1.8.0, the Mods feature allows you to run additional scripts when upgrading or installing an app. Just put the scripts in question with the **AppID** followed by the `-preinstall`, `-upgrade`, `-install` or `-installed` suffix in the **mods** folder. -> Runs before upgrade/install: `AppID-preinstall.ps1` -> Runs during upgrade/install (before install check): `AppID-upgrade.ps1`/`AppID-install.ps1` -> Runs after upgrade/install has been confirmed: `AppID-installed.ps1` + +> Runs before upgrade/install: `AppID-preinstall.ps1`
      +Runs during upgrade/install (before install check): `AppID-upgrade.ps1`/`AppID-install.ps1`
      +Runs after upgrade/install has been confirmed: `AppID-installed.ps1` The **-install** mod will be used for upgrades too if **-upgrade** doesn't exist (**WAU** first tries `& $Winget upgrade --id` and if the app isn't detected after that `& $Winget install --id` is tried).
      `AppID-install.ps1` is recommended because it's used in **both** scenarios. > Example:
      -> If you want to run a script that removes the shortcut from **%PUBLIC%\Desktop** (we don't want to fill the desktop with shortcuts our users can't delete) just after installing **Acrobat Reader DC** (32-bit), prepare a powershell script that removes the Public Desktop shortcut **Acrobat Reader DC.lnk** and name your script like this: `Adobe.Acrobat.Reader.32-bit-installed.ps1` and put it in the **mods** folder. +If you want to run a script that removes the shortcut from **%PUBLIC%\Desktop** (we don't want to fill the desktop with shortcuts our users can't delete) just after installing **Acrobat Reader DC** (32-bit), prepare a powershell script that removes the Public Desktop shortcut **Acrobat Reader DC.lnk** and name your script like this: `Adobe.Acrobat.Reader.32-bit-installed.ps1` and put it in the **mods** folder. You can find more information on [Winget-Install Repo](https://github.com/Romanitho/Winget-Install#custom-mods), as it's a related feature.
      Read more in the `README.md` under the directory **mods**. @@ -186,7 +184,7 @@ https://github.com/Romanitho/Winget-AutoUpdate/discussions/categories/mods ### Winget native parameters Another finess is the **AppID** followed by the `-override` suffix as a **text file** (.**txt**) that you can place under the **mods** folder. > Example:
      -> **Canneverbe.CDBurnerXP-override.txt** with the content `ADDLOCAL=All REMOVE=Desktop_Shortcut /qn` +**Canneverbe.CDBurnerXP-override.txt** with the content `ADDLOCAL=All REMOVE=Desktop_Shortcut /qn` This will use the **content** of the text file as a native **winget --override** parameter when upgrading (as proposed by [JonNesovic](https://github.com/JonNesovic) in [Mod for --override argument #244](https://github.com/Romanitho/Winget-AutoUpdate/discussions/244#discussion-4637666)). From 4f7d077a7694672f50d5581fa98208b0761bf052 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Thu, 4 May 2023 11:13:52 +0200 Subject: [PATCH 126/131]
      missing --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e1eb6ee..1838abd 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ Use White List instead of Black List. This setting will not create the "excluded **-ListPath**
      Get Black/White List from external Path (**URL/UNC/Local/GPO**) - download/copy to Winget-AutoUpdate installation location if external list is newer.
      **PATH** must end with a Directory, not a File...
      -...if the external Path is an **URL** and the web host doesn't respond with a date/time header for the file (i.e **GitHub**) then the file is always downloaded! +...if the external Path is an **URL** and the web host doesn't respond with a date/time header for the file (i.e **GitHub**) then the file is always downloaded!
      If `-ListPath` is set to **GPO** the Black/White List can be managed from within the GPO itself under **Application GPO Blacklist**/**Application GPO Whitelist**.
      Thanks to [Weatherlights](https://github.com/Weatherlights) in [#256 (reply in thread)](https://github.com/Romanitho/Winget-AutoUpdate/discussions/256#discussioncomment-4710599)! From bb060ca0f7482604be2f5034e4d0852ac096a072 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Thu, 4 May 2023 11:26:33 +0200 Subject: [PATCH 127/131] all good :) --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 1838abd..4e92818 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,8 @@ Use White List instead of Black List. This setting will not create the "excluded **-ListPath**
      Get Black/White List from external Path (**URL/UNC/Local/GPO**) - download/copy to Winget-AutoUpdate installation location if external list is newer.
      **PATH** must end with a Directory, not a File...
      -...if the external Path is an **URL** and the web host doesn't respond with a date/time header for the file (i.e **GitHub**) then the file is always downloaded!
      -If `-ListPath` is set to **GPO** the Black/White List can be managed from within the GPO itself under **Application GPO Blacklist**/**Application GPO Whitelist**.
      -Thanks to [Weatherlights](https://github.com/Weatherlights) in [#256 (reply in thread)](https://github.com/Romanitho/Winget-AutoUpdate/discussions/256#discussioncomment-4710599)! +...if the external Path is an **URL** and the web host doesn't respond with a date/time header for the file (i.e **GitHub**) then the file is always downloaded! +If `-ListPath` is set to **GPO** the Black/White List can be managed from within the GPO itself under **Application GPO Blacklist**/**Application GPO Whitelist**. Thanks to [Weatherlights](https://github.com/Weatherlights) in [#256 (reply in thread)](https://github.com/Romanitho/Winget-AutoUpdate/discussions/256#discussioncomment-4710599)! **-ModsPath**
      Get Mods from external Path (**URL/UNC/Local/AzureBlob**) - download/copy to `mods` in Winget-AutoUpdate installation location if external mods are newer.
      @@ -115,10 +114,11 @@ For **URL**: This requires a site directory with **Directory Listing Enabled** a
    • Notepad++.Notepad++-uninstalled.ps1
    ``` -Validated on **IIS/Apache**.
    -**Nota bene IIS** :
    -- The extension **.ps1** must be added as **MIME Types** (text/powershell-script) otherwise it's displayed in the listing but can't be opened -- Files with special characters in the filename can't be opened by default from an IIS server - config must be administrated: **Enable Allow double escaping** in '**Request Filtering**' +Validated on **IIS/Apache**. + +>**Nota bene IIS** : +>- The extension **.ps1** must be added as **MIME Types** (text/powershell-script) otherwise it's displayed in the listing but can't be opened +>- Files with special characters in the filename can't be opened by default from an IIS server - config must be administrated: **Enable Allow double escaping** in '**Request Filtering**' For **AzureBlob**: This requires the parameter **-AzureBlobURL** to be set with an appropriate Azure Blob Storage URL including the SAS token. See **-AzureBlobURL** for more information. From 438f323013a5d313abe8ff37eceb2d7ad7e033f8 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Thu, 4 May 2023 14:26:36 +0200 Subject: [PATCH 128/131] update doc --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4e92818..0564a9b 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,7 @@ Use White List instead of Black List. This setting will not create the "excluded Get Black/White List from external Path (**URL/UNC/Local/GPO**) - download/copy to Winget-AutoUpdate installation location if external list is newer.
    **PATH** must end with a Directory, not a File...
    ...if the external Path is an **URL** and the web host doesn't respond with a date/time header for the file (i.e **GitHub**) then the file is always downloaded! + If `-ListPath` is set to **GPO** the Black/White List can be managed from within the GPO itself under **Application GPO Blacklist**/**Application GPO Whitelist**. Thanks to [Weatherlights](https://github.com/Weatherlights) in [#256 (reply in thread)](https://github.com/Romanitho/Winget-AutoUpdate/discussions/256#discussioncomment-4710599)! **-ModsPath**
    @@ -126,7 +127,8 @@ For **AzureBlob**: This requires the parameter **-AzureBlobURL** to be set with Used in conjunction with the **-ModsPath** parameter to provide the Azure Storage Blob URL with SAS token. The SAS token must, at a minimum, have 'Read' and 'List' permissions. It is recommended to set the permisions at the container level and rotate the SAS token on a regular basis. Ensure the container reflects the same structure as found under the initial `mods` folder. (From version 1.16.4). **-InstallUserContext**
    -Install WAU with system and **user** context executions (From version 1.15.3). Applications installed in system context will be ignored under user context. +Install WAU with system and **user** context executions (From version 1.15.3).
    +Applications installed in system context will be ignored under user context. **-BypassListForUsers**
    Bypass Black/White list when run in user context (From version 1.15.0). @@ -165,9 +167,9 @@ See https://github.com/Romanitho/Winget-AutoUpdate/discussions/88 From version 1.8.0, the Mods feature allows you to run additional scripts when upgrading or installing an app. Just put the scripts in question with the **AppID** followed by the `-preinstall`, `-upgrade`, `-install` or `-installed` suffix in the **mods** folder. -> Runs before upgrade/install: `AppID-preinstall.ps1`
    -Runs during upgrade/install (before install check): `AppID-upgrade.ps1`/`AppID-install.ps1`
    -Runs after upgrade/install has been confirmed: `AppID-installed.ps1` +>- Runs before upgrade/install: `AppID-preinstall.ps1`
    +>- Runs during upgrade/install (before install check): `AppID-upgrade.ps1`/`AppID-install.ps1`
    +>- Runs after upgrade/install has been confirmed: `AppID-installed.ps1` The **-install** mod will be used for upgrades too if **-upgrade** doesn't exist (**WAU** first tries `& $Winget upgrade --id` and if the app isn't detected after that `& $Winget install --id` is tried).
    `AppID-install.ps1` is recommended because it's used in **both** scenarios. From 1884982935c38825d87846979fc0aa6364b295f7 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 5 May 2023 00:29:45 +0000 Subject: [PATCH 129/131] Changed version to 1.17.5-1 --- Winget-AutoUpdate/Version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Winget-AutoUpdate/Version.txt b/Winget-AutoUpdate/Version.txt index ceddc85..9bf9e24 100644 --- a/Winget-AutoUpdate/Version.txt +++ b/Winget-AutoUpdate/Version.txt @@ -1 +1 @@ -1.17.5-0 \ No newline at end of file +1.17.5-1 \ No newline at end of file From 1e8d9f956e681d7a769a71946fc328c93454861a Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Fri, 5 May 2023 17:18:34 +0200 Subject: [PATCH 130/131] ncipollo/release-action@v1.12.0 --- .github/workflows/WAU-CreateNewVersion.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/WAU-CreateNewVersion.yml b/.github/workflows/WAU-CreateNewVersion.yml index e510994..58d417b 100644 --- a/.github/workflows/WAU-CreateNewVersion.yml +++ b/.github/workflows/WAU-CreateNewVersion.yml @@ -62,7 +62,7 @@ jobs: zip -r WAU uninstall.bat - name: Create release - uses: "ncipollo/release-action@v1" + uses: "ncipollo/release-action@v1.12.0" with: tag: "v${{ steps.versioning.outputs.version }}" prerelease: ${{ github.event.inputs.pre-release }} From cad3005ace2e030bf954aac9960dc0ebbc1d2da7 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Sat, 6 May 2023 14:10:56 +0200 Subject: [PATCH 131/131] update (#339) * Symlink full WAU folder * Create symlink for install.log * Handle WAU-install symlinks in Updates and Uninstallations #333 * restore whitespaces for linebreak * MCKanpolat/auto-semver-action@1.0.10 * MCKanpolat/auto-semver-action@1.0.10 * Changed version to 1.17.5-0 * Doc accuracy * Bug fix + doc * Cleanning *
    * last review *
    missing * all good :) * update doc * Changed version to 1.17.5-1 * ncipollo/release-action@v1.12.0 --------- Co-authored-by: Fabian Seitz Co-authored-by: Fabian Seitz Co-authored-by: github-actions[bot] --- .../workflows/WAU-AutoCreatePreVersion.yml | 2 +- .github/workflows/WAU-CreateNewVersion.yml | 4 +- README.md | 114 +++++++++--------- Winget-AutoUpdate-Install.ps1 | 5 +- Winget-AutoUpdate/Version.txt | 2 +- Winget-AutoUpdate/WAU-Uninstall.ps1 | 8 ++ Winget-AutoUpdate/Winget-Upgrade.ps1 | 2 +- .../functions/Invoke-PostUpdateActions.ps1 | 5 + Winget-AutoUpdate/functions/Start-Init.ps1 | 8 +- 9 files changed, 87 insertions(+), 63 deletions(-) diff --git a/.github/workflows/WAU-AutoCreatePreVersion.yml b/.github/workflows/WAU-AutoCreatePreVersion.yml index 953e187..e0a10a0 100644 --- a/.github/workflows/WAU-AutoCreatePreVersion.yml +++ b/.github/workflows/WAU-AutoCreatePreVersion.yml @@ -53,7 +53,7 @@ jobs: fetch-depth: 0 - name: Auto Increment Semver Action - uses: MCKanpolat/auto-semver-action@1.0.9 + uses: MCKanpolat/auto-semver-action@1.0.10 id: versioning with: releaseType: prerelease diff --git a/.github/workflows/WAU-CreateNewVersion.yml b/.github/workflows/WAU-CreateNewVersion.yml index bf7dbd1..58d417b 100644 --- a/.github/workflows/WAU-CreateNewVersion.yml +++ b/.github/workflows/WAU-CreateNewVersion.yml @@ -31,7 +31,7 @@ jobs: lfs: "true" - name: Auto Increment Semver Action - uses: MCKanpolat/auto-semver-action@1.0.9 + uses: MCKanpolat/auto-semver-action@1.0.10 id: versioning with: releaseType: ${{ github.event.inputs.version }} @@ -62,7 +62,7 @@ jobs: zip -r WAU uninstall.bat - name: Create release - uses: "ncipollo/release-action@v1" + uses: "ncipollo/release-action@v1.12.0" with: tag: "v${{ steps.versioning.outputs.version }}" prerelease: ${{ github.event.inputs.pre-release }} diff --git a/README.md b/README.md index a296d7a..2df3491 100644 --- a/README.md +++ b/README.md @@ -29,8 +29,9 @@ By default, scripts and components will be placed in ProgramData location (insid From version 1.9.0 (on new installations) WAU runs everyday at 6AM. You can now configure the frequency with `-UpdatesInterval` option (Daily, BiDaily, Weekly, BiWeekly or Monthly). You can also add `-UpdatesAtLogon` parameter to run at user logon and keep this option activated like previous versions (recommanded). ### Log location -You can find logs in install location, in logs folder. -If **Intune Management Extension** is installed, a **SymLink** (WAU-updates.log) is created under **C:\ProgramData\Microsoft\IntuneManagementExtension\Logs** +You can find logs in install location, in logs folder.
    +If **Intune Management Extension** is installed, a **SymLink** (WAU-updates.log) is created under **C:\ProgramData\Microsoft\IntuneManagementExtension\Logs**
    +If you are deploying winget Apps with [Winget-Install](https://github.com/Romanitho/Winget-Install) a **SymLink** (WAU-install.log) is also created under **C:\ProgramData\Microsoft\IntuneManagementExtension\Logs** ### "Unknown" App version As explained in this [post](https://github.com/microsoft/winget-cli/issues/1255), Winget cannot detect the current version of some installed apps. We decided to skip managing these apps with WAU to avoid retries each time WAU runs: @@ -71,41 +72,41 @@ Simply uninstall it from your programs: ## Advanced installation You can run the `Winget-AutoUpdate-Install.ps1` script with parameters : -**-Silent** +**-Silent**
    Install Winget-AutoUpdate and prerequisites silently. -**-MaxLogFiles** -Specify number of allowed log files. -Default is 3 out of 0-99: -Setting MaxLogFiles to 0 don't delete any old archived log files. +**-MaxLogFiles**
    +Specify number of allowed log files.
    +Default is 3 out of 0-99:
    +Setting MaxLogFiles to 0 don't delete any old archived log files.
    Setting it to 1 keeps the original one and just let it grow. -**-MaxLogSize** -Specify the size of the log file in bytes before rotating. +**-MaxLogSize**
    +Specify the size of the log file in bytes before rotating.
    Default is 1048576 = 1 MB (ca. 7500 lines) -**-WingetUpdatePath** +**-WingetUpdatePath**
    Specify Winget-AutoUpdate installation location. Default: `C:\ProgramData\Winget-AutoUpdate` (Recommended to leave default). -**-DoNotUpdate** +**-DoNotUpdate**
    Do not run Winget-AutoUpdate after installation. By default, Winget-AutoUpdate is run just after installation. -**-DisableWAUAutoUpdate** +**-DisableWAUAutoUpdate**
    Disable Winget-AutoUpdate update checking. By default, WAU auto updates if new version is available on Github. -**-UseWhiteList** +**-UseWhiteList**
    Use White List instead of Black List. This setting will not create the "excluded_apps.txt" but "included_apps.txt". -**-ListPath** -Get Black/White List from external Path (**URL/UNC/Local/GPO**) - download/copy to Winget-AutoUpdate installation location if external list is newer. -**PATH** must end with a Directory, not a File... +**-ListPath**
    +Get Black/White List from external Path (**URL/UNC/Local/GPO**) - download/copy to Winget-AutoUpdate installation location if external list is newer.
    +**PATH** must end with a Directory, not a File...
    ...if the external Path is an **URL** and the web host doesn't respond with a date/time header for the file (i.e **GitHub**) then the file is always downloaded! -If `-ListPath` is set to **GPO** the Black/White List can be managed from within the GPO itself under **Application GPO Blacklist**/**Application GPO Whitelist**. -Thanks to [Weatherlights](https://github.com/Weatherlights) in [#256 (reply in thread)](https://github.com/Romanitho/Winget-AutoUpdate/discussions/256#discussioncomment-4710599)! +If `-ListPath` is set to **GPO** the Black/White List can be managed from within the GPO itself under **Application GPO Blacklist**/**Application GPO Whitelist**. Thanks to [Weatherlights](https://github.com/Weatherlights) in [#256 (reply in thread)](https://github.com/Romanitho/Winget-AutoUpdate/discussions/256#discussioncomment-4710599)! -**-ModsPath** -Get Mods from external Path (**URL/UNC/Local/AzureBlob**) - download/copy to `mods` in Winget-AutoUpdate installation location if external mods are newer. + +**-ModsPath**
    +Get Mods from external Path (**URL/UNC/Local/AzureBlob**) - download/copy to `mods` in Winget-AutoUpdate installation location if external mods are newer.
    For **URL**: This requires a site directory with **Directory Listing Enabled** and no index page overriding the listing of files (or an index page with href listing of all the **Mods** to be downloaded): ``` @@ -118,49 +119,50 @@ For **URL**: This requires a site directory with **Directory Listing Enabled** a ``` Validated on **IIS/Apache**. -**Nota bene IIS** : - - The extension **.ps1** must be added as **MIME Types** (text/powershell-script) otherwise it's displayed in the listing but can't be opened - - Files with special characters in the filename can't be opened by default from an IIS server - config must be administrated: **Enable Allow double escaping** in '**Request Filtering**' +>**Nota bene IIS** : +>- The extension **.ps1** must be added as **MIME Types** (text/powershell-script) otherwise it's displayed in the listing but can't be opened +>- Files with special characters in the filename can't be opened by default from an IIS server - config must be administrated: **Enable Allow double escaping** in '**Request Filtering**' For **AzureBlob**: This requires the parameter **-AzureBlobURL** to be set with an appropriate Azure Blob Storage URL including the SAS token. See **-AzureBlobURL** for more information. -**-AzureBlobURL** +**-AzureBlobURL**
    Used in conjunction with the **-ModsPath** parameter to provide the Azure Storage Blob URL with SAS token. The SAS token must, at a minimum, have 'Read' and 'List' permissions. It is recommended to set the permisions at the container level and rotate the SAS token on a regular basis. Ensure the container reflects the same structure as found under the initial `mods` folder. (From version 1.16.4). -**-InstallUserContext** -Install WAU with system and **user** context executions (From version 1.15.3). +**-InstallUserContext**
    +Install WAU with system and **user** context executions (From version 1.15.3).
    +Applications installed in system context will be ignored under user context. -**-BypassListForUsers** +**-BypassListForUsers**
    Bypass Black/White list when run in user context (From version 1.15.0). -**-NoClean** +**-NoClean**
    Keep critical files when installing/uninstalling. This setting will keep "excluded_apps.txt", "included_apps.txt", "mods" and "logs" as they were. -**-DesktopShortcut** +**-DesktopShortcut**
    Create a shortcut for user interaction on the Desktop to run task `Winget-AutoUpdate` (From version 1.15.0). -**-StartMenuShortcut** +**-StartMenuShortcut**
    Create shortcuts for user interaction in the Start Menu to run task `Winget-AutoUpdate`, open Logs and Web Help (From version 1.15.0). -**-NotificationLevel** +**-NotificationLevel**
    Specify the Notification level: Full (Default, displays all notification), SuccessOnly (Only displays notification for success) or None (Does not show any popup). -**-UpdatesAtLogon** +**-UpdatesAtLogon**
    Set WAU to run at user logon. -**-UpdatesInterval** +**-UpdatesInterval**
    Specify the update frequency: Daily (Default), BiDaily, Weekly, BiWeekly, Monthly or Never. Can be set to 'Never' in combination with '-UpdatesAtLogon' for instance. -**-UpdatesAtTime** +**-UpdatesAtTime**
    Specify the time of the update interval execution time. Default 6AM. (From version 1.15.0). -**-UserApproval** +**-UserApproval**
    Specify if user approval is needed before updating apps -**-RunOnMetered** +**-RunOnMetered**
    Run WAU on metered connection. Default No. -**-Uninstall** +**-Uninstall**
    Remove scheduled tasks and scripts. ## Intune/SCCM use @@ -169,37 +171,39 @@ See https://github.com/Romanitho/Winget-AutoUpdate/discussions/88 ## Custom scripts (Mods feature) From version 1.8.0, the Mods feature allows you to run additional scripts when upgrading or installing an app. Just put the scripts in question with the **AppID** followed by the `-preinstall`, `-upgrade`, `-install` or `-installed` suffix in the **mods** folder. -> Runs before upgrade/install: `AppID-preinstall.ps1` -> Runs during upgrade/install (before install check): `AppID-upgrade.ps1`/`AppID-install.ps1` -> Runs after upgrade/install has been confirmed: `AppID-installed.ps1` -The **-install** mod will be used for upgrades too if **-upgrade** doesn't exist (**WAU** first tries `& $Winget upgrade --id` and if the app isn't detected after that `& $Winget install --id` is tried). +>- Runs before upgrade/install: `AppID-preinstall.ps1`
    +>- Runs during upgrade/install (before install check): `AppID-upgrade.ps1`/`AppID-install.ps1`
    +>- Runs after upgrade/install has been confirmed: `AppID-installed.ps1` + +The **-install** mod will be used for upgrades too if **-upgrade** doesn't exist (**WAU** first tries `& $Winget upgrade --id` and if the app isn't detected after that `& $Winget install --id` is tried).
    `AppID-install.ps1` is recommended because it's used in **both** scenarios. -> Example: -If you want to run a script that removes the shortcut from **%PUBLIC%\Desktop** (we don't want to fill the desktop with shortcuts our users can't delete) just after installing **Acrobat Reader DC** (32-bit), prepare a powershell script that removes the Public Desktop shortcut **Acrobat Reader DC.lnk** and name your script like this: -`Adobe.Acrobat.Reader.32-bit-installed.ps1` and put it in the **mods** folder. +> Example:
    +If you want to run a script that removes the shortcut from **%PUBLIC%\Desktop** (we don't want to fill the desktop with shortcuts our users can't delete) just after installing **Acrobat Reader DC** (32-bit), prepare a powershell script that removes the Public Desktop shortcut **Acrobat Reader DC.lnk** and name your script like this: `Adobe.Acrobat.Reader.32-bit-installed.ps1` and put it in the **mods** folder. -You can find more information on [Winget-Install Repo](https://github.com/Romanitho/Winget-Install#custom-mods), as it's a related feature. +You can find more information on [Winget-Install Repo](https://github.com/Romanitho/Winget-Install#custom-mods), as it's a related feature.
    Read more in the `README.md` under the directory **mods**. -Share your mods with the community: +Share your mods with the community:
    + https://github.com/Romanitho/Winget-AutoUpdate/discussions/categories/mods ### Winget native parameters Another finess is the **AppID** followed by the `-override` suffix as a **text file** (.**txt**) that you can place under the **mods** folder. -> Example: -> **Canneverbe.CDBurnerXP-override.txt** with the content `ADDLOCAL=All REMOVE=Desktop_Shortcut /qn` + +> Example:
    +**Canneverbe.CDBurnerXP-override.txt** with the content `ADDLOCAL=All REMOVE=Desktop_Shortcut /qn` + This will use the **content** of the text file as a native **winget --override** parameter when upgrading (as proposed by [JonNesovic](https://github.com/JonNesovic) in [Mod for --override argument #244](https://github.com/Romanitho/Winget-AutoUpdate/discussions/244#discussion-4637666)). ## GPO Management -In an enterprise environment it's crucial that different groups can have different settings in applications etc. or to implement other mandatory settings, i.e for security/management reasons. -**WAU** doesn't have any setting that can be changed except for when installing (or editing the registry/the task `Winget-AutoUpdate` as **Admin**). -With the use of **ADML/ADMX** files you can manage every **WAU** setting from within **GPO**. -They will be detected/evaluated during the next run of **WAU** (taking effect before any actions). -The **GPO ADMX/ADML** validated with: -[Windows 10 - Validate ADMX for Ingestion](https://developer.vmware.com/samples/7115/windows-10---validate-admx-for-ingestion) +In an enterprise environment it's crucial that different groups can have different settings in applications etc. or to implement other mandatory settings, i.e for security/management reasons.
    +**WAU** doesn't have any setting that can be changed except for when installing (or editing the registry/the task `Winget-AutoUpdate` as **Admin**).
    +With the use of **ADML/ADMX** files you can manage every **WAU** setting from within **GPO**.
    +They will be detected/evaluated during the next run of **WAU** (taking effect before any actions).
    +The **GPO ADMX/ADML** validated with: [Windows 10 - Validate ADMX for Ingestion](https://developer.vmware.com/samples/7115/windows-10---validate-admx-for-ingestion)
    Read more in the `README.md` under the directory **Policies**. ![image](https://user-images.githubusercontent.com/102996177/213920242-7ff8e2b4-d926-4407-b860-1e5922e29c3e.png) @@ -211,4 +215,4 @@ In some cases, you need to "unblock" the `install.bat` file (Windows Defender Sm * As reported by [soredake](https://github.com/soredake), Powershell from MsStore is not supported with WAU in system context. See https://github.com/Romanitho/Winget-AutoUpdate/issues/113 ## Optimization -Feel free to give us any suggestions or optimizations in code and support us by adding a star :). +Feel free to give us any suggestions or optimizations in code and support us by adding a star :) diff --git a/Winget-AutoUpdate-Install.ps1 b/Winget-AutoUpdate-Install.ps1 index 37ef98d..a7a784a 100644 --- a/Winget-AutoUpdate-Install.ps1 +++ b/Winget-AutoUpdate-Install.ps1 @@ -71,7 +71,7 @@ Install WAU with system and user context executions Specify if user approval is needed before updating apps .PARAMETER BypassListForUsers -Configure WAU to bypass the Black/White list when run in user context +Configure WAU to bypass the Black/White list when run in user context. Applications installed in system context will be ignored under user context. .EXAMPLE .\Winget-AutoUpdate-Install.ps1 -Silent -DoNotUpdate -MaxLogFiles 4 -MaxLogSize 2097152 @@ -442,6 +442,9 @@ function Uninstall-WingetAutoUpdate { if (Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-updates.log") { Remove-Item -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-updates.log" -Force -ErrorAction SilentlyContinue | Out-Null } + if (Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-install.log") { + Remove-Item -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-install.log" -Force -ErrorAction SilentlyContinue | Out-Null + } } else { #Keep critical files diff --git a/Winget-AutoUpdate/Version.txt b/Winget-AutoUpdate/Version.txt index 250f359..9bf9e24 100644 --- a/Winget-AutoUpdate/Version.txt +++ b/Winget-AutoUpdate/Version.txt @@ -1 +1 @@ -1.17.4 \ No newline at end of file +1.17.5-1 \ No newline at end of file diff --git a/Winget-AutoUpdate/WAU-Uninstall.ps1 b/Winget-AutoUpdate/WAU-Uninstall.ps1 index 44209c6..7bb2a91 100644 --- a/Winget-AutoUpdate/WAU-Uninstall.ps1 +++ b/Winget-AutoUpdate/WAU-Uninstall.ps1 @@ -65,6 +65,14 @@ try { Remove-Item -Path "${env:Public}\Desktop\WAU - Check for updated Apps.lnk" -Force | Out-Null } + #Remove Intune Logs if they are existing + if (Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-updates.log") { + Remove-Item -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-updates.log" -Force -ErrorAction SilentlyContinue | Out-Null + } + if (Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-install.log") { + Remove-Item -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-install.log" -Force -ErrorAction SilentlyContinue | Out-Null + } + Write-host "Uninstallation succeeded!" -ForegroundColor Green } else { diff --git a/Winget-AutoUpdate/Winget-Upgrade.ps1 b/Winget-AutoUpdate/Winget-Upgrade.ps1 index 0589799..667bb3c 100644 --- a/Winget-AutoUpdate/Winget-Upgrade.ps1 +++ b/Winget-AutoUpdate/Winget-Upgrade.ps1 @@ -263,7 +263,7 @@ if (Test-Network) { $Script:InstallOK = 0 #Trick under user context when -BypassListForUsers is used - if ($IsSystem -eq $false -and $WAUConfig.WAU_BypassListForUsers -eq $true) { + if ($IsSystem -eq $false -and $WAUConfig.WAU_BypassListForUsers -eq 1) { Write-ToLog "Bypass system list in user context is Enabled." $UseWhiteList = $false $toSkip = $null diff --git a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 index 605e10a..af6c881 100644 --- a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 +++ b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 @@ -10,6 +10,11 @@ function Invoke-PostUpdateActions { Write-ToLog "-> Creating SymLink for log file in Intune Management Extension log folder" "yellow" New-Item -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-updates.log" -ItemType SymbolicLink -Value $LogFile -Force -ErrorAction SilentlyContinue | Out-Null } + #Check if Intune Management Extension Logs folder and WAU-install.log exists, make symlink + if ((Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs") -and (Test-Path "$WorkingDir\logs\install.log") -and !(Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-install.log")) { + Write-host "`nCreating SymLink for log file (WAU-install) in Intune Management Extension log folder" -ForegroundColor Yellow + New-Item -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-install.log" -ItemType SymbolicLink -Value "$WorkingDir\logs\install.log" -Force -ErrorAction SilentlyContinue | Out-Null + } Write-ToLog "-> Checking prerequisites..." "yellow" diff --git a/Winget-AutoUpdate/functions/Start-Init.ps1 b/Winget-AutoUpdate/functions/Start-Init.ps1 index e0b6a83..ac5d5c5 100644 --- a/Winget-AutoUpdate/functions/Start-Init.ps1 +++ b/Winget-AutoUpdate/functions/Start-Init.ps1 @@ -45,10 +45,14 @@ function Start-Init { #Check if Intune Management Extension Logs folder and WAU-updates.log exists, make symlink if ((Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs") -and !(Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-updates.log")) { - Write-host "`nCreating SymLink for log file in Intune Management Extension log folder" -ForegroundColor Yellow + Write-host "`nCreating SymLink for log file (WAU-updates) in Intune Management Extension log folder" -ForegroundColor Yellow New-Item -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-updates.log" -ItemType SymbolicLink -Value $LogFile -Force -ErrorAction SilentlyContinue | Out-Null } - + #Check if Intune Management Extension Logs folder and WAU-install.log exists, make symlink + if ((Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs") -and (Test-Path "$WorkingDir\logs\install.log") -and !(Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-install.log")) { + Write-host "`nCreating SymLink for log file (WAU-install) in Intune Management Extension log folder" -ForegroundColor Yellow + New-Item -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-install.log" -ItemType SymbolicLink -Value "$WorkingDir\logs\install.log" -Force -ErrorAction SilentlyContinue | Out-Null + } if ($caller -eq "Winget-Upgrade.ps1") { #Log file