Skip to content

Commit 952e29b

Browse files
committed
Updated to WAU 2.2.0
1 parent 593e7cc commit 952e29b

33 files changed

Lines changed: 377 additions & 639 deletions

Sources/WAU/Winget-AutoUpdate-Install.ps1

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,7 @@ function Install-WingetAutoUpdate {
263263
New-ItemProperty $regPath -Name Publisher -Value "Romanitho" -Force | Out-Null
264264
New-ItemProperty $regPath -Name URLInfoAbout -Value "https://github.com/Romanitho/Winget-AutoUpdate" -Force | Out-Null
265265
New-ItemProperty $regPath -Name WAU_NotificationLevel -Value $NotificationLevel -Force | Out-Null
266-
if ($WAUVersion -match "-") {
267-
New-ItemProperty $regPath -Name WAU_UpdatePrerelease -Value 1 -PropertyType DWord -Force | Out-Null
268-
}
269-
else {
270-
New-ItemProperty $regPath -Name WAU_UpdatePrerelease -Value 0 -PropertyType DWord -Force | Out-Null
271-
}
266+
New-ItemProperty $regPath -Name WAU_UpdatePrerelease -Value 0 -PropertyType DWord -Force | Out-Null
272267
New-ItemProperty $regPath -Name WAU_PostUpdateActions -Value 0 -PropertyType DWord -Force | Out-Null
273268
New-ItemProperty $regPath -Name WAU_MaxLogFiles -Value $MaxLogFiles -PropertyType DWord -Force | Out-Null
274269
New-ItemProperty $regPath -Name WAU_MaxLogSize -Value $MaxLogSize -PropertyType DWord -Force | Out-Null
72.3 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.4.35-1
1+
1.21.13

Sources/WAU/Winget-AutoUpdate/WAU-Policies.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,4 @@ if ($WAUConfig.WAU_RunGPOManagement -eq 1) {
9898
$WAUConfig.PSObject.Properties | Where-Object { $_.Name -like "WAU_*" } | Select-Object Name, Value | Out-File -Encoding default -FilePath $GPOLogFile -Append
9999
}
100100

101-
Exit 0
101+
Exit 0

Sources/WAU/Winget-AutoUpdate/Winget-Install.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ function Uninstall-App ($AppID, $AppArgs) {
263263

264264
#Function to Add app to WAU white list
265265
function Add-WAUWhiteList ($AppID) {
266-
#Check if WAU default intall path is defined
266+
#Check if WAU default install path is defined
267267
if ($WAUInstallLocation) {
268268
$WhiteList = "$WAUInstallLocation\included_apps.txt"
269269
#Create included_apps.txt if it doesn't exist
@@ -272,7 +272,7 @@ function Add-WAUWhiteList ($AppID) {
272272
}
273273
Write-ToLog "-> Add $AppID to WAU included_apps.txt"
274274
#Add App to "included_apps.txt"
275-
Add-Content -path $WhiteList -Value "`n$AppID" -Force
275+
Add-Content -Path $WhiteList -Value "`n$AppID" -Force
276276
#Remove duplicate and blank lines
277277
$file = Get-Content $WhiteList | Select-Object -Unique | Where-Object { $_.trim() -ne "" } | Sort-Object
278278
$file | Out-File $WhiteList
@@ -281,7 +281,7 @@ function Add-WAUWhiteList ($AppID) {
281281

282282
#Function to Remove app from WAU white list
283283
function Remove-WAUWhiteList ($AppID) {
284-
#Check if WAU default intall path exists
284+
#Check if WAU default install path exists
285285
$WhiteList = "$WAUInstallLocation\included_apps.txt"
286286
if (Test-Path $WhiteList) {
287287
Write-ToLog "-> Remove $AppID from WAU included_apps.txt"
@@ -314,7 +314,7 @@ $Script:IsElevated = $CurrentPrincipal.IsInRole([Security.Principal.WindowsBuilt
314314
$WAURegKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\"
315315
$Script:WAUInstallLocation = Get-ItemProperty $WAURegKey -ErrorAction SilentlyContinue | Select-Object -ExpandProperty InstallLocation
316316

317-
#LogPath initialisation
317+
#LogPath initialization
318318
if (!($LogPath)) {
319319
#If LogPath is not set, get WAU log path
320320
if ($WAUInstallLocation) {
@@ -326,7 +326,7 @@ if (!($LogPath)) {
326326
}
327327
}
328328

329-
#Logs initialisation
329+
#Logs initialization
330330
if (!(Test-Path $LogPath)) {
331331
New-Item -ItemType Directory -Force -Path $LogPath | Out-Null
332332
}
@@ -372,7 +372,7 @@ if ($IsElevated -eq $True) {
372372
$null = Update-Winget
373373
#Reload Winget command
374374
$Script:Winget = Get-WingetCmd
375-
#Run Scope Machine funtion
375+
#Run Scope Machine function
376376
Add-ScopeMachine
377377
}
378378
else {

Sources/WAU/Winget-AutoUpdate/Winget-Upgrade.ps1

Lines changed: 49 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@ Get-ChildItem "$WorkingDir\functions" -File -Filter "*.ps1" -Depth 0 | ForEach-O
1111
#Config console output encoding
1212
$null = cmd /c ''
1313
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
14+
$Script:ProgressPreference = 'SilentlyContinue'
1415

15-
#Log initialisation
16+
#Set GitHub Repo
17+
$Script:GitHub_Repo = "Winget-AutoUpdate"
18+
19+
#Log initialization
1620
$LogFile = "$WorkingDir\logs\updates.log"
1721

1822
#Check if running account is system or interactive logon
@@ -22,6 +26,21 @@ $Script:SessionID = [System.Diagnostics.Process]::GetCurrentProcess().SessionId
2226

2327
#Check if running as system
2428
if ($IsSystem) {
29+
#If log file doesn't exist, force create it
30+
if (!(Test-Path -Path $LogFile)) {
31+
Write-ToLog "New log file created"
32+
}
33+
# Check if Intune Management Extension Logs folder exists
34+
if ((Test-Path -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs" -ErrorAction SilentlyContinue)) {
35+
# Check if symlink WAU-updates.log exists, make symlink (doesn't work under ServiceUI)
36+
if (!(Test-Path -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-updates.log" -ErrorAction SilentlyContinue)) {
37+
$symLink = New-Item -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-updates.log" -ItemType SymbolicLink -Value $LogFile -Force -ErrorAction SilentlyContinue
38+
}
39+
# Check if install.log and symlink WAU-install.log exists, make symlink (doesn't work under ServiceUI)
40+
if ((Test-Path -Path ('{0}\logs\install.log' -f $WorkingDir) -ErrorAction SilentlyContinue) -and !(Test-Path -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-install.log" -ErrorAction SilentlyContinue)) {
41+
$symLink = (New-Item -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-install.log" -ItemType SymbolicLink -Value ('{0}\logs\install.log' -f $WorkingDir) -Force -Confirm:$False -ErrorAction SilentlyContinue)
42+
}
43+
}
2544
#Check if running with session ID 0
2645
if ($SessionID -eq 0) {
2746
#Check if ServiceUI exists
@@ -30,20 +49,33 @@ if ($IsSystem) {
3049
#Check if any connected user
3150
$explorerprocesses = @(Get-CimInstance -Query "SELECT * FROM Win32_Process WHERE Name='explorer.exe'" -ErrorAction SilentlyContinue)
3251
if ($explorerprocesses.Count -gt 0) {
52+
if ($symLink) {
53+
$null = (New-Item "$WorkingDir\logs\symlink.txt" -Value $symLink -Force)
54+
}
3355
#Rerun WAU in system context with ServiceUI
3456
& $WorkingDir\ServiceUI.exe -process:explorer.exe $env:windir\System32\wscript.exe \`"$WorkingDir\Invisible.vbs\`" \`"powershell.exe -NoProfile -ExecutionPolicy Bypass -File \`"\`"$WorkingDir\winget-upgrade.ps1\`"\`"\`"
3557
Exit 0
3658
}
3759
else {
3860
Write-ToLog -LogMsg "CHECK FOR APP UPDATES (System context)" -IsHeader
61+
if ($symLink) {
62+
Write-ToLog "SymLink for log file created in Intune Management Extension log folder"
63+
}
3964
}
4065
}
4166
else {
4267
Write-ToLog -LogMsg "CHECK FOR APP UPDATES (System context - No ServiceUI)" -IsHeader
68+
if ($symLink) {
69+
Write-ToLog "SymLink for log file created in Intune Management Extension log folder"
70+
}
4371
}
4472
}
4573
else {
4674
Write-ToLog -LogMsg "CHECK FOR APP UPDATES (System context - Connected user)" -IsHeader
75+
if (Test-Path "$WorkingDir\logs\symlink.txt") {
76+
Write-ToLog "SymLink for log file created in Intune Management Extension log folder"
77+
Remove-Item "$WorkingDir\logs\symlink.txt" -Force
78+
}
4779
}
4880
}
4981
else {
@@ -80,14 +112,14 @@ if ($IsSystem) {
80112
#LogRotation if System
81113
$LogRotate = Invoke-LogRotation $LogFile $MaxLogFiles $MaxLogSize
82114
if ($LogRotate -eq $False) {
83-
Write-ToLog "An Exception occured during Log Rotation..."
115+
Write-ToLog "An Exception occurred during Log Rotation..."
84116
}
85117

86118
#Run post update actions if necessary if run as System
87119
if (!($WAUConfig.WAU_PostUpdateActions -eq 0)) {
88120
Invoke-PostUpdateActions
89121
}
90-
#Run Scope Machine funtion if run as System
122+
#Run Scope Machine function if run as System
91123
Add-ScopeMachine
92124
}
93125

@@ -121,7 +153,7 @@ if (Test-Network) {
121153
#Get Available Version
122154
$Script:WAUAvailableVersion = Get-WAUAvailableVersion
123155
#Compare
124-
if ([version]$WAUAvailableVersion.Replace("-", ".") -ne [version]$WAUCurrentVersion.Replace("-", ".")) {
156+
if ([version]$WAUAvailableVersion.replace("-n", "") -gt [version]$WAUCurrentVersion.replace("-n", "")) {
125157
#If new version is available, update it
126158
Write-ToLog "WAU Available version: $WAUAvailableVersion" "Yellow"
127159
Update-WAU
@@ -157,7 +189,13 @@ if (Test-Network) {
157189
$Script:ReachNoPath = $False
158190
}
159191
if ($NewList) {
160-
Write-ToLog "Newer List downloaded/copied to local path: $($WAUConfig.InstallLocation.TrimEnd(" ", "\"))" "Yellow"
192+
if ($AlwaysDownloaded) {
193+
Write-ToLog "List downloaded/copied to local path: $($WAUConfig.InstallLocation.TrimEnd(" ", "\"))" "Yellow"
194+
}
195+
else {
196+
Write-ToLog "Newer List downloaded/copied to local path: $($WAUConfig.InstallLocation.TrimEnd(" ", "\"))" "Yellow"
197+
}
198+
$Script:AlwaysDownloaded = $False
161199
}
162200
else {
163201
if ($WAUConfig.WAU_UseWhiteList -and (Test-Path "$WorkingDir\included_apps.txt")) {
@@ -239,17 +277,15 @@ if (Test-Network) {
239277
#Fix and count the array if GPO List as ERROR handling!
240278
if ($GPOList) {
241279
if ($UseWhiteList) {
242-
$WhiteList = $toUpdate.GetUpperBound(0)
243-
if ($null -eq $WhiteList) {
280+
if (-not $toUpdate) {
244281
Write-ToLog "Critical: Whitelist doesn't exist in GPO, exiting..." "Red"
245282
New-Item "$WorkingDir\logs\error.txt" -Value "Whitelist doesn't exist in GPO" -Force
246283
Exit 1
247284
}
248285
foreach ($app in $toUpdate) { Write-ToLog "Include app ${app}" }
249286
}
250287
else {
251-
$BlackList = $toSkip.GetUpperBound(0)
252-
if ($null -eq $BlackList) {
288+
if (-not $toSkip) {
253289
Write-ToLog "Critical: Blacklist doesn't exist in GPO, exiting..." "Red"
254290
New-Item "$WorkingDir\logs\error.txt" -Value "Blacklist doesn't exist in GPO" -Force
255291
Exit 1
@@ -262,14 +298,12 @@ if (Test-Network) {
262298
Write-ToLog "Checking application updates on Winget Repository..." "yellow"
263299
$outdated = Get-WingetOutdatedApps
264300

265-
#If something unusual happened
266-
if ($outdated -like "An unusual*") {
301+
#If something unusual happened or no update found
302+
if ($outdated -like "No update found.*") {
267303
Write-ToLog "$outdated" "cyan"
268-
$outdated = $False
269304
}
270-
271305
#Run only if $outdated is populated!
272-
if ($outdated) {
306+
else {
273307
#Log list of app to update
274308
foreach ($app in $outdated) {
275309
#List available updates
@@ -346,13 +380,6 @@ if (Test-Network) {
346380
#Check if user context is activated during system run
347381
if ($IsSystem) {
348382

349-
#Adds SymLink if Intune managed
350-
$IntuneLogPath = "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs"
351-
if ((Test-Path "$IntuneLogPath") -and !(Test-Path "$IntuneLogPath\WAU-updates.log")) {
352-
Write-ToLog "Creating SymLink for log file (WAU-updates) in Intune Management Extension log folder" "Yellow"
353-
New-Item -Path "$IntuneLogPath\WAU-updates.log" -ItemType SymbolicLink -Value $LogFile -Force -ErrorAction SilentlyContinue | Out-Null
354-
}
355-
356383
#Run WAU in user context if feature is activated
357384
if ($WAUConfig.WAU_UserContext -eq 1) {
358385

@@ -376,7 +403,7 @@ if (Test-Network) {
376403
Write-ToLog "No explorer process found / Nobody interactively logged on..."
377404
}
378405
Else {
379-
#Get Winget system apps to excape them befor running user context
406+
#Get Winget system apps to escape them before running user context
380407
Write-ToLog "User logged on, get a list of installed Winget apps in System context..."
381408
Get-WingetSystemApps
382409

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Google.Chrome*
2+
Microsoft.Edge*
3+
Microsoft.Office
4+
Microsoft.OneDrive
5+
Microsoft.RemoteDesktopClient
6+
Microsoft.Teams*
7+
Mozilla.Firefox*
8+
Opera.Opera*
9+
TeamViewer.TeamViewer*

Sources/WAU/Winget-AutoUpdate/functions/Add-ScopeMachine.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Function to configure the prefered scope option as Machine
1+
#Function to configure the preferred scope option as Machine
22
function Add-ScopeMachine {
33

44
#Get Settings path for system or current user
@@ -29,4 +29,4 @@ function Add-ScopeMachine {
2929
}
3030

3131
$ConfigFile | ConvertTo-Json -Depth 100 | Out-File $SettingsPath -Encoding utf8 -Force
32-
}
32+
}

Sources/WAU/Winget-AutoUpdate/functions/Confirm-Installation.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ Function Confirm-Installation ($AppName, $AppVer) {
2121
else {
2222
return $false
2323
}
24-
}
24+
}

Sources/WAU/Winget-AutoUpdate/functions/Get-AZCopy.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ Function Get-AZCopy ($WingetUpdatePath) {
4747
$AZCopyCurrentVersion = $AZCopyVersionRegex.Match($AZCopyCurrentVersion).Value
4848
Write-ToLog "AZCopy version $AZCopyCurrentVersion installed"
4949
}
50-
}
50+
}

0 commit comments

Comments
 (0)