Added Notification Level Feature

pull/63/head
Romain 2022-04-24 10:51:51 +02:00 committed by GitHub
parent bcd9d02ce4
commit e40d5f441a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 66 additions and 45 deletions

View File

@ -25,6 +25,9 @@ Use White List instead of Black List. This setting will not create the "exclude_
.PARAMETER Uninstall
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).
.EXAMPLE
.\winget-install-and-update.ps1 -Silent -DoNotUpdate
@ -41,6 +44,7 @@ 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")] [Switch] $NotificationLevel = "Full"
)
@ -191,6 +195,7 @@ function Install-WingetAutoUpdate{
<WAUautoupdate>$(!($DisableWAUAutoUpdate))</WAUautoupdate>
<WAUprerelease>False</WAUprerelease>
<UseWAUWhiteList>$UseWhiteList</UseWAUWhiteList>
<NotificationLevel>$NotificationLevel</NotificationLevel>
</app>
"@
$ConfigXML.Save("$WingetUpdatePath\config\config.xml")

View File

@ -20,7 +20,7 @@ Function Get-NotifLocale {
}
#Get locale XML file content
Write-Log "Notification Langugage : $LocaleDisplayName" "Cyan"
Write-Log "Notification Level: $NotificationLevel. Notification Language: $LocaleDisplayName" "Cyan"
[xml]$Script:NotifLocale = Get-Content $LocaleFile -Encoding UTF8 -ErrorAction SilentlyContinue
}

View File

@ -2,16 +2,24 @@
function Get-WAUConfig{
#Get config file
[xml]$WAUConfig = Get-Content "$WorkingDir\config\config.xml" -Encoding UTF8 -ErrorAction SilentlyContinue
#Check if WAU is configured for Black or White List
if ($true -eq [System.Convert]::ToBoolean($WAUConfig.app.UseWAUWhiteList)){
Write-Log "WAU uses White List config"
$Script:UseWhiteList = $true
}
else{
Write-Log "WAU uses Black List config"
$Script:UseWhiteList = $false
}
#Get Notification Level
if ($WAUConfig.app.NotificationLevel){
$Script:NotificationLevel = $WAUConfig.app.NotificationLevel
}
else{
#Default: Full
$Script:NotificationLevel = $full
}
}

View File

@ -2,6 +2,8 @@
function Start-NotifTask ($Title,$Message,$MessageType,$Balise) {
if (($NotificationLevel -eq "Full") -or ($NotificationLevel -eq "SuccessOnly" -and $MessageType -eq "Success")) {
#Add XML variables
[xml]$ToastTemplate = @"
<toast launch="ms-get-started://redirect?id=apps_action">
@ -57,4 +59,6 @@ function Start-NotifTask ($Title,$Message,$MessageType,$Balise) {
#Wait for notification to display
Start-Sleep 3
}
}

View File

@ -11,6 +11,9 @@ Get-ChildItem "$WorkingDir\functions" | ForEach-Object {. $_.FullName}
#Run log initialisation function
Start-Init
#Get WAU Configurations
Get-WAUConfig
#Get Notif Locale function
Get-NotifLocale
@ -40,11 +43,12 @@ if (Test-Network){
}
#Get White or Black list
Get-WAUConfig
if ($UseWhiteList){
Write-Log "WAU uses White List config"
$toUpdate = Get-IncludedApps
}
else{
Write-Log "WAU uses Black List config"
$toSkip = Get-ExcludedApps
}

View File

@ -1,2 +1,2 @@
@echo off
powershell -Command "Get-ChildItem -Path '%~dp0' -Recurse | Unblock-File; Start-Process powershell.exe -Argument '-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"" '" -Verb RunAs

View File

@ -1,2 +1,2 @@
@echo off
powershell -Command "Get-ChildItem -Path '%~dp0' -Recurse | Unblock-File; Start-Process powershell.exe -Argument '-executionpolicy bypass -file """%~dp0Winget-AutoUpdate-Install.ps1"" -Uninstall'" -Verb RunAs
powershell -Command "Get-ChildItem -Path '%~dp0' -Recurse | Unblock-File; Start-Process powershell.exe -Argument '-noprofile -executionpolicy bypass -file """%~dp0Winget-AutoUpdate-Install.ps1"" -Uninstall'" -Verb RunAs