Added Notification Level Feature
parent
bcd9d02ce4
commit
e40d5f441a
|
@ -25,6 +25,9 @@ Use White List instead of Black List. This setting will not create the "exclude_
|
||||||
.PARAMETER Uninstall
|
.PARAMETER Uninstall
|
||||||
Remove scheduled tasks and scripts.
|
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
|
.EXAMPLE
|
||||||
.\winget-install-and-update.ps1 -Silent -DoNotUpdate
|
.\winget-install-and-update.ps1 -Silent -DoNotUpdate
|
||||||
|
|
||||||
|
@ -41,6 +44,7 @@ param(
|
||||||
[Parameter(Mandatory=$False)] [Switch] $DisableWAUAutoUpdate = $false,
|
[Parameter(Mandatory=$False)] [Switch] $DisableWAUAutoUpdate = $false,
|
||||||
[Parameter(Mandatory=$False)] [Switch] $Uninstall = $false,
|
[Parameter(Mandatory=$False)] [Switch] $Uninstall = $false,
|
||||||
[Parameter(Mandatory=$False)] [Switch] $UseWhiteList = $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>
|
<WAUautoupdate>$(!($DisableWAUAutoUpdate))</WAUautoupdate>
|
||||||
<WAUprerelease>False</WAUprerelease>
|
<WAUprerelease>False</WAUprerelease>
|
||||||
<UseWAUWhiteList>$UseWhiteList</UseWAUWhiteList>
|
<UseWAUWhiteList>$UseWhiteList</UseWAUWhiteList>
|
||||||
|
<NotificationLevel>$NotificationLevel</NotificationLevel>
|
||||||
</app>
|
</app>
|
||||||
"@
|
"@
|
||||||
$ConfigXML.Save("$WingetUpdatePath\config\config.xml")
|
$ConfigXML.Save("$WingetUpdatePath\config\config.xml")
|
||||||
|
|
|
@ -20,7 +20,7 @@ Function Get-NotifLocale {
|
||||||
}
|
}
|
||||||
|
|
||||||
#Get locale XML file content
|
#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
|
[xml]$Script:NotifLocale = Get-Content $LocaleFile -Encoding UTF8 -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
}
|
}
|
|
@ -2,16 +2,24 @@
|
||||||
|
|
||||||
function Get-WAUConfig{
|
function Get-WAUConfig{
|
||||||
|
|
||||||
|
#Get config file
|
||||||
[xml]$WAUConfig = Get-Content "$WorkingDir\config\config.xml" -Encoding UTF8 -ErrorAction SilentlyContinue
|
[xml]$WAUConfig = Get-Content "$WorkingDir\config\config.xml" -Encoding UTF8 -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
#Check if WAU is configured for Black or White List
|
#Check if WAU is configured for Black or White List
|
||||||
if ($true -eq [System.Convert]::ToBoolean($WAUConfig.app.UseWAUWhiteList)){
|
if ($true -eq [System.Convert]::ToBoolean($WAUConfig.app.UseWAUWhiteList)){
|
||||||
Write-Log "WAU uses White List config"
|
|
||||||
$Script:UseWhiteList = $true
|
$Script:UseWhiteList = $true
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
Write-Log "WAU uses Black List config"
|
|
||||||
$Script:UseWhiteList = $false
|
$Script:UseWhiteList = $false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#Get Notification Level
|
||||||
|
if ($WAUConfig.app.NotificationLevel){
|
||||||
|
$Script:NotificationLevel = $WAUConfig.app.NotificationLevel
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
#Default: Full
|
||||||
|
$Script:NotificationLevel = $full
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
function Start-NotifTask ($Title,$Message,$MessageType,$Balise) {
|
function Start-NotifTask ($Title,$Message,$MessageType,$Balise) {
|
||||||
|
|
||||||
|
if (($NotificationLevel -eq "Full") -or ($NotificationLevel -eq "SuccessOnly" -and $MessageType -eq "Success")) {
|
||||||
|
|
||||||
#Add XML variables
|
#Add XML variables
|
||||||
[xml]$ToastTemplate = @"
|
[xml]$ToastTemplate = @"
|
||||||
<toast launch="ms-get-started://redirect?id=apps_action">
|
<toast launch="ms-get-started://redirect?id=apps_action">
|
||||||
|
@ -58,3 +60,5 @@ function Start-NotifTask ($Title,$Message,$MessageType,$Balise) {
|
||||||
Start-Sleep 3
|
Start-Sleep 3
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -11,6 +11,9 @@ Get-ChildItem "$WorkingDir\functions" | ForEach-Object {. $_.FullName}
|
||||||
#Run log initialisation function
|
#Run log initialisation function
|
||||||
Start-Init
|
Start-Init
|
||||||
|
|
||||||
|
#Get WAU Configurations
|
||||||
|
Get-WAUConfig
|
||||||
|
|
||||||
#Get Notif Locale function
|
#Get Notif Locale function
|
||||||
Get-NotifLocale
|
Get-NotifLocale
|
||||||
|
|
||||||
|
@ -40,11 +43,12 @@ if (Test-Network){
|
||||||
}
|
}
|
||||||
|
|
||||||
#Get White or Black list
|
#Get White or Black list
|
||||||
Get-WAUConfig
|
|
||||||
if ($UseWhiteList){
|
if ($UseWhiteList){
|
||||||
|
Write-Log "WAU uses White List config"
|
||||||
$toUpdate = Get-IncludedApps
|
$toUpdate = Get-IncludedApps
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
Write-Log "WAU uses Black List config"
|
||||||
$toSkip = Get-ExcludedApps
|
$toSkip = Get-ExcludedApps
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
@echo off
|
@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
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
@echo off
|
@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
|
Loading…
Reference in New Issue