vscode auto-format
parent
c095e377d7
commit
a4112a5154
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 }
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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 }
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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 }
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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'"
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 }
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue