Merge pull request #67 from Romanitho/Update-Frequency-Option
Added Update frequency optionpull/71/head v1.9.0
commit
659ff700e3
10
README.md
10
README.md
|
@ -32,6 +32,8 @@ Scheduled task is set to run:
|
|||
- At 6AM Everyday (with the -StartWhenAvailable option to be sure it is run at least once a day)
|
||||
This way, even without connected user, powered on computers get updated anyway.
|
||||
|
||||
> From version 1.9.0 (on new installations) WAU runs everyday at 6AM. You can now configure the frequency with `-UpdatesInterval` option (Daily, 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 log folder.
|
||||
|
||||
|
@ -71,6 +73,14 @@ Use White List instead of Black List. This setting will not create the "exclude_
|
|||
**-NotificationLevel**
|
||||
Specify the Notification level: Full (Default, displays all notification), SuccessOnly (Only displays notification for success) or None (Does not show any popup).
|
||||
|
||||
|
||||
**-UpdatesAtLogon**
|
||||
Set WAU to run at user logon.
|
||||
|
||||
**-UpdatesInterval**
|
||||
Specify the update frequency: Daily (Default), Weekly, Biweekly or Monthly.
|
||||
|
||||
|
||||
**-Uninstall**
|
||||
Remove scheduled tasks and scripts.
|
||||
|
||||
|
|
|
@ -28,12 +28,21 @@ Remove scheduled tasks and scripts.
|
|||
.PARAMETER NotificationLevel
|
||||
Specify the Notification level: Full (Default, displays all notification), SuccessOnly (Only displays notification for success) or None (Does not show any popup).
|
||||
|
||||
.PARAMETER UpdatesAtLogon
|
||||
Set WAU to run at user logon.
|
||||
|
||||
.PARAMETER UpdatesInterval
|
||||
Specify the update frequency: Daily (Default), Weekly, Biweekly or Monthly.
|
||||
|
||||
.EXAMPLE
|
||||
.\winget-install-and-update.ps1 -Silent -DoNotUpdate
|
||||
|
||||
.EXAMPLE
|
||||
.\winget-install-and-update.ps1 -Silent -UseWhiteList
|
||||
|
||||
.EXAMPLE
|
||||
.\winget-install-and-update.ps1 -Silent -UpdatesAtLogon -UpdatesInterval Weekly
|
||||
|
||||
#>
|
||||
|
||||
[CmdletBinding()]
|
||||
|
@ -44,7 +53,9 @@ param(
|
|||
[Parameter(Mandatory=$False)] [Switch] $DisableWAUAutoUpdate = $false,
|
||||
[Parameter(Mandatory=$False)] [Switch] $Uninstall = $false,
|
||||
[Parameter(Mandatory=$False)] [Switch] $UseWhiteList = $false,
|
||||
[Parameter(Mandatory=$False)] [ValidateSet("Full","SuccessOnly","None")] [String] $NotificationLevel = "Full"
|
||||
[Parameter(Mandatory=$False)] [ValidateSet("Full","SuccessOnly","None")] [String] $NotificationLevel = "Full",
|
||||
[Parameter(Mandatory=$False)] [Switch] $UpdatesAtLogon = $false,
|
||||
[Parameter(Mandatory=$False)] [ValidateSet("Daily","Weekly","BiWeekly","Monthly")] [String] $UpdatesInterval = "Daily"
|
||||
)
|
||||
|
||||
|
||||
|
@ -170,13 +181,27 @@ function Install-WingetAutoUpdate{
|
|||
|
||||
# Settings for the scheduled task for Updates
|
||||
$taskAction = New-ScheduledTaskAction –Execute "powershell.exe" -Argument "-NoProfile -ExecutionPolicy Bypass -File `"$($WingetUpdatePath)\winget-upgrade.ps1`""
|
||||
$taskTrigger1 = New-ScheduledTaskTrigger -AtLogOn
|
||||
$taskTrigger2 = New-ScheduledTaskTrigger -Daily -At 6AM
|
||||
$taskTriggers = @()
|
||||
if ($UpdatesAtLogon){
|
||||
$tasktriggers += New-ScheduledTaskTrigger -AtLogOn
|
||||
}
|
||||
if ($UpdatesInterval -eq "Daily"){
|
||||
$tasktriggers += New-ScheduledTaskTrigger -Daily -At 6AM
|
||||
}
|
||||
elseif ($UpdatesInterval -eq "Weekly"){
|
||||
$tasktriggers += New-ScheduledTaskTrigger -Weekly -At 6AM -DaysOfWeek 2
|
||||
}
|
||||
elseif ($UpdatesInterval -eq "BiWeekly"){
|
||||
$tasktriggers += New-ScheduledTaskTrigger -Weekly -At 6AM -DaysOfWeek 2 -WeeksInterval 2
|
||||
}
|
||||
elseif ($UpdatesInterval -eq "Monthly"){
|
||||
$tasktriggers += New-ScheduledTaskTrigger -Weekly -At 6AM -DaysOfWeek 2 -WeeksInterval 4
|
||||
}
|
||||
$taskUserPrincipal = New-ScheduledTaskPrincipal -UserId S-1-5-18 -RunLevel Highest
|
||||
$taskSettings = New-ScheduledTaskSettingsSet -Compatibility Win8 -StartWhenAvailable -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -ExecutionTimeLimit 03:00:00
|
||||
|
||||
# Set up the task, and register it
|
||||
$task = New-ScheduledTask -Action $taskAction -Principal $taskUserPrincipal -Settings $taskSettings -Trigger $taskTrigger2,$taskTrigger1
|
||||
$task = New-ScheduledTask -Action $taskAction -Principal $taskUserPrincipal -Settings $taskSettings -Trigger $taskTriggers
|
||||
Register-ScheduledTask -TaskName 'Winget-AutoUpdate' -InputObject $task -Force | Out-Null
|
||||
|
||||
# Settings for the scheduled task for Notifications
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
@echo off
|
||||
powershell -Command "Get-ChildItem -Path '%~dp0' -Recurse | Unblock-File; Start-Process powershell.exe -Argument '-noprofile -executionpolicy bypass -file """%~dp0Winget-AutoUpdate-Install.ps1"" '" -Verb RunAs
|
||||
powershell -Command "Get-ChildItem -Path '%~dp0' -Recurse | Unblock-File; Start-Process powershell.exe -Argument '-noprofile -executionpolicy bypass -file """%~dp0Winget-AutoUpdate-Install.ps1"" -UpdatesAtLogon'" -Verb RunAs
|
||||
|
|
Loading…
Reference in New Issue