From a4112a51545c48c2da7b9f2675333c3d02752178 Mon Sep 17 00:00:00 2001 From: romanitho <96626929+Romanitho@users.noreply.github.com> Date: Tue, 18 Oct 2022 15:23:39 +0200 Subject: [PATCH] vscode auto-format --- Winget-AutoUpdate-Install.ps1 | 16 ++++++++-------- Winget-AutoUpdate/WAU-Uninstall.ps1 | 2 +- Winget-AutoUpdate/functions/Get-AppInfo.ps1 | 2 +- Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 | 2 +- Winget-AutoUpdate/functions/Get-IncludedApps.ps1 | 2 +- .../functions/Get-WingetOutdatedApps.ps1 | 6 +++--- .../functions/Invoke-PostUpdateActions.ps1 | 2 +- Winget-AutoUpdate/functions/Start-NotifTask.ps1 | 2 +- Winget-AutoUpdate/functions/Test-ListPath.ps1 | 16 ++++++++-------- Winget-AutoUpdate/functions/Test-Network.ps1 | 6 +++--- .../functions/Test-PendingReboot.ps1 | 6 +++--- Winget-AutoUpdate/user-run.ps1 | 6 +++--- Winget-AutoUpdate/winget-notify.ps1 | 2 +- Winget-AutoUpdate/winget-upgrade.ps1 | 12 ++++++------ 14 files changed, 41 insertions(+), 41 deletions(-) diff --git a/Winget-AutoUpdate-Install.ps1 b/Winget-AutoUpdate-Install.ps1 index 7ecb36b..5b3a850 100644 --- a/Winget-AutoUpdate-Install.ps1 +++ b/Winget-AutoUpdate-Install.ps1 @@ -1,4 +1,4 @@ -<# +<# .SYNOPSIS Configure Winget to daily update installed apps. @@ -211,7 +211,7 @@ function Install-WingetAutoUpdate { } else { #Keep critical files - Get-ChildItem -Path $WingetUpdatePath -Exclude *.txt,mods,logs | Remove-Item -Recurse -Force + Get-ChildItem -Path $WingetUpdatePath -Exclude *.txt, mods, logs | Remove-Item -Recurse -Force } } Copy-Item -Path "$PSScriptRoot\Winget-AutoUpdate\*" -Destination $WingetUpdatePath -Recurse -Force -ErrorAction SilentlyContinue @@ -223,7 +223,7 @@ function Install-WingetAutoUpdate { Copy-Item -Path "$PSScriptRoot\included_apps.txt" -Destination $WingetUpdatePath -Recurse -Force -ErrorAction SilentlyContinue } else { - if (!$ListPath){ + if (!$ListPath) { New-Item -Path $WingetUpdatePath -Name "included_apps.txt" -ItemType "file" -ErrorAction SilentlyContinue | Out-Null } } @@ -233,7 +233,7 @@ function Install-WingetAutoUpdate { Copy-Item -Path "$PSScriptRoot\included_apps.txt" -Destination $WingetUpdatePath -Recurse -Force -ErrorAction SilentlyContinue } else { - if (!$ListPath){ + if (!$ListPath) { New-Item -Path $WingetUpdatePath -Name "included_apps.txt" -ItemType "file" -ErrorAction SilentlyContinue | Out-Null } } @@ -330,16 +330,16 @@ function Install-WingetAutoUpdate { if (!$RunOnMetered) { New-ItemProperty $regPath -Name WAU_DoNotRunOnMetered -Value 1 -PropertyType DWord -Force | Out-Null } - if ($ListPath){ + if ($ListPath) { New-ItemProperty $regPath -Name WAU_ListPath -Value $ListPath -Force | Out-Null } - if ($BypassListForUsers){ + if ($BypassListForUsers) { New-ItemProperty $regPath -Name WAU_BypassListForUsers -Value 1 -PropertyType DWord -Force | Out-Null } #Set ACL for users on logfile $LogFile = "$WingetUpdatePath\logs\updates.log" - if (test-path $LogFile){ + if (test-path $LogFile) { $NewAcl = Get-Acl -Path $LogFile $identity = New-Object System.Security.Principal.SecurityIdentifier S-1-5-11 $fileSystemRights = "Modify" @@ -393,7 +393,7 @@ function Uninstall-WingetAutoUpdate { } else { #Keep critical files - Get-ChildItem -Path $InstallLocation -Exclude *.txt,mods,logs | Remove-Item -Recurse -Force + Get-ChildItem -Path $InstallLocation -Exclude *.txt, mods, logs | Remove-Item -Recurse -Force } Get-ScheduledTask -TaskName "Winget-AutoUpdate" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False Get-ScheduledTask -TaskName "Winget-AutoUpdate-Notify" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False diff --git a/Winget-AutoUpdate/WAU-Uninstall.ps1 b/Winget-AutoUpdate/WAU-Uninstall.ps1 index f0c95e1..d3f99d6 100644 --- a/Winget-AutoUpdate/WAU-Uninstall.ps1 +++ b/Winget-AutoUpdate/WAU-Uninstall.ps1 @@ -45,7 +45,7 @@ try { } else { #Keep critical files - Get-ChildItem -Path $InstallLocation -Exclude *.txt,mods,logs | Remove-Item -Recurse -Force + Get-ChildItem -Path $InstallLocation -Exclude *.txt, mods, logs | Remove-Item -Recurse -Force } Get-ScheduledTask -TaskName "Winget-AutoUpdate" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False Get-ScheduledTask -TaskName "Winget-AutoUpdate-Notify" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False diff --git a/Winget-AutoUpdate/functions/Get-AppInfo.ps1 b/Winget-AutoUpdate/functions/Get-AppInfo.ps1 index 247b917..38937e4 100644 --- a/Winget-AutoUpdate/functions/Get-AppInfo.ps1 +++ b/Winget-AutoUpdate/functions/Get-AppInfo.ps1 @@ -5,7 +5,7 @@ Function Get-AppInfo ($AppID) { $String = & $winget show $AppID --accept-source-agreements -s winget | Out-String #Search for Release Note info - $ReleaseNote = [regex]::match($String,"(?<=Release Notes Url: )(.*)(?=\n)").Groups[0].Value + $ReleaseNote = [regex]::match($String, "(?<=Release Notes Url: )(.*)(?=\n)").Groups[0].Value #Return Release Note return $ReleaseNote diff --git a/Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 b/Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 index bcd26ca..04b3ef8 100644 --- a/Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 +++ b/Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 @@ -4,7 +4,7 @@ function Get-ExcludedApps { if (Test-Path "$WorkingDir\excluded_apps.txt") { - return (Get-Content -Path "$WorkingDir\excluded_apps.txt").Trim() | Where-Object{$_.length -gt 0} + return (Get-Content -Path "$WorkingDir\excluded_apps.txt").Trim() | Where-Object { $_.length -gt 0 } } diff --git a/Winget-AutoUpdate/functions/Get-IncludedApps.ps1 b/Winget-AutoUpdate/functions/Get-IncludedApps.ps1 index e9a31a5..c930203 100644 --- a/Winget-AutoUpdate/functions/Get-IncludedApps.ps1 +++ b/Winget-AutoUpdate/functions/Get-IncludedApps.ps1 @@ -4,7 +4,7 @@ function Get-IncludedApps { if (Test-Path "$WorkingDir\included_apps.txt") { - return (Get-Content -Path "$WorkingDir\included_apps.txt").Trim() | Where-Object{$_.length -gt 0} + return (Get-Content -Path "$WorkingDir\included_apps.txt").Trim() | Where-Object { $_.length -gt 0 } } diff --git a/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 b/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 index 1b209d2..adc3165 100644 --- a/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 +++ b/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 @@ -39,7 +39,7 @@ 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 - 1; $i++) { $line = $lines[$i] if ($line) { $software = [Software]::new() @@ -55,8 +55,8 @@ function Get-WingetOutdatedApps { #If current user is not system, remove system apps from list if ($IsSystem -eq $false) { $SystemApps = Get-Content -Path "$WorkingDir\winget_system_apps.txt" - $upgradeList = $upgradeList | Where-Object {$SystemApps -notcontains $_.Id} + $upgradeList = $upgradeList | Where-Object { $SystemApps -notcontains $_.Id } } - return $upgradeList | Sort-Object {Get-Random} + return $upgradeList | Sort-Object { Get-Random } } \ No newline at end of file diff --git a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 index b1609e1..e751c1f 100644 --- a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 +++ b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 @@ -89,7 +89,7 @@ function Invoke-PostUpdateActions { #Set new User Context task and Set system task readable/runnable for all users $UserTask = Get-ScheduledTask -TaskName "Winget-AutoUpdate-UserContext" -ErrorAction SilentlyContinue - if (!$UserTask){ + if (!$UserTask) { # Settings for the scheduled task in User context $taskAction = New-ScheduledTaskAction -Execute "wscript.exe" -Argument "`"$($WorkingDir)\Invisible.vbs`" `"powershell.exe -NoProfile -ExecutionPolicy Bypass -File `"`"`"$($WorkingDir)\winget-upgrade.ps1`"`"" $taskUserPrincipal = New-ScheduledTaskPrincipal -GroupId S-1-5-11 diff --git a/Winget-AutoUpdate/functions/Start-NotifTask.ps1 b/Winget-AutoUpdate/functions/Start-NotifTask.ps1 index f635e6b..aae33fc 100644 --- a/Winget-AutoUpdate/functions/Start-NotifTask.ps1 +++ b/Winget-AutoUpdate/functions/Start-NotifTask.ps1 @@ -5,7 +5,7 @@ function Start-NotifTask ($Title, $Message, $MessageType, $Balise, $OnClickActio if (($WAUConfig.WAU_NotificationLevel -eq "Full") -or ($WAUConfig.WAU_NotificationLevel -eq "SuccessOnly" -and $MessageType -eq "Success") -or ($UserRun)) { #Prepare OnClickAction (if set) - if ($OnClickAction){ + if ($OnClickAction) { $ToastOnClickAction = "activationType='protocol' launch='$OnClickAction'" } diff --git a/Winget-AutoUpdate/functions/Test-ListPath.ps1 b/Winget-AutoUpdate/functions/Test-ListPath.ps1 index 8e2a43e..f7dbdc2 100644 --- a/Winget-AutoUpdate/functions/Test-ListPath.ps1 +++ b/Winget-AutoUpdate/functions/Test-ListPath.ps1 @@ -2,16 +2,16 @@ function Test-ListPath ($ListPath, $UseWhiteList, $WingetUpdatePath) { # URL, UNC or Local Path - if ($UseWhiteList){ - $ListType="included_apps.txt" + if ($UseWhiteList) { + $ListType = "included_apps.txt" } else { - $ListType="excluded_apps.txt" + $ListType = "excluded_apps.txt" } # Get local and external list paths - $LocalList = -join($WingetUpdatePath, "\", $ListType) - $ExternalList = -join($ListPath, "\", $ListType) + $LocalList = -join ($WingetUpdatePath, "\", $ListType) + $ExternalList = -join ($ListPath, "\", $ListType) # Check if a list exists if (Test-Path "$LocalList") { @@ -19,8 +19,8 @@ function Test-ListPath ($ListPath, $UseWhiteList, $WingetUpdatePath) { } # If path is URL - if ($ListPath -like "http*"){ - $ExternalList = -join($ListPath, "/", $ListType) + if ($ListPath -like "http*") { + $ExternalList = -join ($ListPath, "/", $ListType) $wc = New-Object System.Net.WebClient try { $wc.OpenRead("$ExternalList").Close() | Out-Null @@ -41,7 +41,7 @@ function Test-ListPath ($ListPath, $UseWhiteList, $WingetUpdatePath) { } # If path is UNC or local else { - if(Test-Path -Path $ExternalList -PathType leaf){ + if (Test-Path -Path $ExternalList -PathType leaf) { $dateExternal = (Get-Item "$ExternalList").LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss") if ($dateExternal -gt $dateLocal) { try { diff --git a/Winget-AutoUpdate/functions/Test-Network.ps1 b/Winget-AutoUpdate/functions/Test-Network.ps1 index 0e331e5..fb92b29 100644 --- a/Winget-AutoUpdate/functions/Test-Network.ps1 +++ b/Winget-AutoUpdate/functions/Test-Network.ps1 @@ -19,7 +19,7 @@ function Test-Network { [void][Windows.Networking.Connectivity.NetworkInformation, Windows, ContentType = WindowsRuntime] $cost = [Windows.Networking.Connectivity.NetworkInformation]::GetInternetConnectionProfile().GetConnectionCost() - if ($cost.ApproachingDataLimit -or $cost.OverDataLimit -or $cost.Roaming -or $cost.BackgroundDataUsageRestricted -or ($cost.NetworkCostType -ne "Unrestricted")){ + if ($cost.ApproachingDataLimit -or $cost.OverDataLimit -or $cost.Roaming -or $cost.BackgroundDataUsageRestricted -or ($cost.NetworkCostType -ne "Unrestricted")) { Write-Log "Metered connection detected." "Yellow" @@ -29,7 +29,7 @@ function Test-Network { return $false } - else{ + else { Write-Log "WAU is configured to force update checking on metered connection" return $true @@ -37,7 +37,7 @@ function Test-Network { } } - else{ + else { return $true diff --git a/Winget-AutoUpdate/functions/Test-PendingReboot.ps1 b/Winget-AutoUpdate/functions/Test-PendingReboot.ps1 index d126aa4..1f80e74 100644 --- a/Winget-AutoUpdate/functions/Test-PendingReboot.ps1 +++ b/Winget-AutoUpdate/functions/Test-PendingReboot.ps1 @@ -9,13 +9,13 @@ function Test-PendingReboot { $WMI_Reg = [WMIClass] "\\$Computer\root\default:StdRegProv" if ($WMI_Reg) { - if (($WMI_Reg.EnumKey($HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\")).sNames -contains 'RebootPending') {$PendingReboot = $true} - if (($WMI_Reg.EnumKey($HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\")).sNames -contains 'RebootRequired') {$PendingReboot = $true} + if (($WMI_Reg.EnumKey($HKLM, "SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\")).sNames -contains 'RebootPending') { $PendingReboot = $true } + if (($WMI_Reg.EnumKey($HKLM, "SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\")).sNames -contains 'RebootRequired') { $PendingReboot = $true } #Checking for SCCM namespace $SCCM_Namespace = Get-WmiObject -Namespace ROOT\CCM\ClientSDK -List -ComputerName $Computer -ErrorAction Ignore if ($SCCM_Namespace) { - if (([WmiClass]"\\$Computer\ROOT\CCM\ClientSDK:CCM_ClientUtilities").DetermineIfRebootPending().RebootPending -eq $true) {$PendingReboot = $true} + if (([WmiClass]"\\$Computer\ROOT\CCM\ClientSDK:CCM_ClientUtilities").DetermineIfRebootPending().RebootPending -eq $true) { $PendingReboot = $true } } } diff --git a/Winget-AutoUpdate/user-run.ps1 b/Winget-AutoUpdate/user-run.ps1 index 1ec5eed..03b410c 100644 --- a/Winget-AutoUpdate/user-run.ps1 +++ b/Winget-AutoUpdate/user-run.ps1 @@ -19,12 +19,12 @@ https://github.com/Romanitho/Winget-AutoUpdate [CmdletBinding()] param( - [Parameter(Mandatory=$False)] [Switch] $Logs = $false, - [Parameter(Mandatory=$False)] [Switch] $Help = $false + [Parameter(Mandatory = $False)] [Switch] $Logs = $false, + [Parameter(Mandatory = $False)] [Switch] $Help = $false ) function Test-WAUisRunning { - If (((Get-ScheduledTask -TaskName 'Winget-AutoUpdate').State -ne 'Ready') -or ((Get-ScheduledTask -TaskName 'Winget-AutoUpdate-UserContext').State -ne 'Ready')) { + If (((Get-ScheduledTask -TaskName 'Winget-AutoUpdate').State -ne 'Ready') -or ((Get-ScheduledTask -TaskName 'Winget-AutoUpdate-UserContext').State -ne 'Ready')) { Return $True } } diff --git a/Winget-AutoUpdate/winget-notify.ps1 b/Winget-AutoUpdate/winget-notify.ps1 index c4f1a1e..0688be6 100644 --- a/Winget-AutoUpdate/winget-notify.ps1 +++ b/Winget-AutoUpdate/winget-notify.ps1 @@ -1,4 +1,4 @@ -#Send Notif Script +#Send Notif Script #get xml notif config [xml]$NotifConf = Get-Content "$env:ProgramData\Winget-AutoUpdate\config\notif.xml" -Encoding UTF8 -ErrorAction SilentlyContinue diff --git a/Winget-AutoUpdate/winget-upgrade.ps1 b/Winget-AutoUpdate/winget-upgrade.ps1 index c241e71..0abd987 100644 --- a/Winget-AutoUpdate/winget-upgrade.ps1 +++ b/Winget-AutoUpdate/winget-upgrade.ps1 @@ -1,4 +1,4 @@ -<# LOAD FUNCTIONS #> +<# LOAD FUNCTIONS #> #Get Working Dir $Script:WorkingDir = $PSScriptRoot @@ -18,7 +18,7 @@ Start-Init if ($IsSystem) { Write-Log "Running in System context" } -else{ +else { Write-Log "Running in User context" } @@ -66,7 +66,7 @@ if (Test-Network) { if ($IsSystem) { Update-WAU } - else{ + else { Write-Log "WAU Needs to run as system to update" "Yellow" } } @@ -76,7 +76,7 @@ if (Test-Network) { } if ($IsSystem) { - #Get External ListPath + #Get External ListPath if ($WAUConfig.WAU_ListPath) { Write-Log "WAU uses External Lists from: $($WAUConfig.WAU_ListPath)" $NewList = Test-ListPath $WAUConfig.WAU_ListPath $WAUConfig.WAU_UseWhiteList $WAUConfig.InstallLocation @@ -121,7 +121,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 $true) { Write-Log "Bypass system list in user context is Enabled." $UseWhiteList = $false $toSkip = $null @@ -179,7 +179,7 @@ if ($IsSystem) { #Run user context scheduled task $UserScheduledTask = Get-ScheduledTask -TaskName "Winget-AutoUpdate-UserContext" -ErrorAction SilentlyContinue - if ($UserScheduledTask){ + if ($UserScheduledTask) { Write-Log "Starting WAU in User context" Start-ScheduledTask $UserScheduledTask.TaskName -ErrorAction SilentlyContinue Exit 0