parent
fc8953ebf2
commit
e0608b295b
|
@ -18,18 +18,18 @@
|
||||||
|
|
||||||
#Get locale file for Notification
|
#Get locale file for Notification
|
||||||
#Default en-US
|
#Default en-US
|
||||||
$DefaultLocal = "$WorkingDir\locale\en-US.xml"
|
$DefaultLocale = "$WorkingDir\locale\en-US.xml"
|
||||||
#Get OS locale
|
#Get OS locale
|
||||||
$Locale = Get-WinSystemLocale
|
$Locale = Get-WinSystemLocale
|
||||||
#Test if OS locale config file exists
|
#Test if OS locale config file exists
|
||||||
$LocalFile = "$WorkingDir\locale\$($locale.Name).xml"
|
$LocaleFile = "$WorkingDir\locale\$($locale.Name).xml"
|
||||||
if(Test-Path $LocalFile){
|
if(Test-Path $LocaleFile){
|
||||||
[xml]$Script:NotifLocal = Get-Content $LocalFile -Encoding UTF8 -ErrorAction SilentlyContinue
|
[xml]$Script:NotifLocale = Get-Content $LocaleFile -Encoding UTF8 -ErrorAction SilentlyContinue
|
||||||
Write-Log "Local : $($locale.Name)"
|
Write-Log "Notification Langugage : $($locale.Name)"
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
[xml]$Script:NotifLocal = Get-Content $DefaultLocal -Encoding UTF8 -ErrorAction SilentlyContinue
|
[xml]$Script:NotifLocale = Get-Content $DefaultLocale -Encoding UTF8 -ErrorAction SilentlyContinue
|
||||||
Write-Log "Local : en-US"
|
Write-Log "Notification Langugage : en-US"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ function Start-NotifTask ($Title,$Message,$MessageType,$Balise) {
|
||||||
Get-ScheduledTask -TaskName "Winget Update Notify" -ErrorAction SilentlyContinue | Start-ScheduledTask -ErrorAction SilentlyContinue
|
Get-ScheduledTask -TaskName "Winget Update Notify" -ErrorAction SilentlyContinue | Start-ScheduledTask -ErrorAction SilentlyContinue
|
||||||
#Wait for notification to display
|
#Wait for notification to display
|
||||||
while ((Get-ScheduledTask -TaskName "Winget Update Notify").State -ne 'Ready') {
|
while ((Get-ScheduledTask -TaskName "Winget Update Notify").State -ne 'Ready') {
|
||||||
Write-Output "Waiting on scheduled task..."
|
Write-Output "Waiting for scheduled task..."
|
||||||
Start-Sleep 3
|
Start-Sleep 3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ function Test-Network {
|
||||||
Write-Log "Checking internet connection..." "Yellow"
|
Write-Log "Checking internet connection..." "Yellow"
|
||||||
while (!$ping -and $timeout -lt 1800){
|
while (!$ping -and $timeout -lt 1800){
|
||||||
try{
|
try{
|
||||||
Invoke-RestMethod -Uri "https://ifconfig.me/"
|
Invoke-RestMethod -Uri "https://api.github.com/zen"
|
||||||
Write-Log "Coonected !" "Green"
|
Write-Log "Coonected !" "Green"
|
||||||
$ping = $true
|
$ping = $true
|
||||||
return
|
return
|
||||||
|
@ -94,8 +94,8 @@ function Test-Network {
|
||||||
if ($timeout -eq 300){
|
if ($timeout -eq 300){
|
||||||
#Send Notif if no connection for 5 min
|
#Send Notif if no connection for 5 min
|
||||||
Write-Log "Notify 'No connection'" "Yellow"
|
Write-Log "Notify 'No connection'" "Yellow"
|
||||||
$Title = $NotifLocal.local.outputs.output[0].title
|
$Title = $NotifLocale.local.outputs.output[0].title
|
||||||
$Message = $NotifLocal.local.outputs.output[0].message
|
$Message = $NotifLocale.local.outputs.output[0].message
|
||||||
$MessageType = "warning"
|
$MessageType = "warning"
|
||||||
$Balise = "connection"
|
$Balise = "connection"
|
||||||
Start-NotifTask $Title $Message $MessageType $Balise
|
Start-NotifTask $Title $Message $MessageType $Balise
|
||||||
|
@ -227,8 +227,8 @@ if ($ping){
|
||||||
|
|
||||||
#Send available update notification
|
#Send available update notification
|
||||||
Write-Log "Updating $($app.Name) from $($app.Version) to $($app.AvailableVersion)..." "Cyan"
|
Write-Log "Updating $($app.Name) from $($app.Version) to $($app.AvailableVersion)..." "Cyan"
|
||||||
$Title = $NotifLocal.local.outputs.output[2].title -f $($app.Name)
|
$Title = $NotifLocale.local.outputs.output[2].title -f $($app.Name)
|
||||||
$Message = $NotifLocal.local.outputs.output[2].message -f $($app.Version), $($app.AvailableVersion)
|
$Message = $NotifLocale.local.outputs.output[2].message -f $($app.Version), $($app.AvailableVersion)
|
||||||
$MessageType = "info"
|
$MessageType = "info"
|
||||||
$Balise = $($app.Name)
|
$Balise = $($app.Name)
|
||||||
Start-NotifTask $Title $Message $MessageType $Balise
|
Start-NotifTask $Title $Message $MessageType $Balise
|
||||||
|
@ -261,8 +261,8 @@ if ($ping){
|
||||||
Write-Log "$($app.Name) updated to $($app.AvailableVersion) !" "Green"
|
Write-Log "$($app.Name) updated to $($app.AvailableVersion) !" "Green"
|
||||||
|
|
||||||
#Send Notif
|
#Send Notif
|
||||||
$Title = $NotifLocal.local.outputs.output[3].title -f $($app.Name)
|
$Title = $NotifLocale.local.outputs.output[3].title -f $($app.Name)
|
||||||
$Message = $NotifLocal.local.outputs.output[3].message -f $($app.AvailableVersion)
|
$Message = $NotifLocale.local.outputs.output[3].message -f $($app.AvailableVersion)
|
||||||
$MessageType = "success"
|
$MessageType = "success"
|
||||||
$Balise = $($app.Name)
|
$Balise = $($app.Name)
|
||||||
Start-NotifTask $Title $Message $MessageType $Balise
|
Start-NotifTask $Title $Message $MessageType $Balise
|
||||||
|
@ -274,8 +274,8 @@ if ($ping){
|
||||||
Write-Log "$($app.Name) update failed." "Red"
|
Write-Log "$($app.Name) update failed." "Red"
|
||||||
|
|
||||||
#Send Notif
|
#Send Notif
|
||||||
$Title = $NotifLocal.local.outputs.output[4].title -f $($app.Name)
|
$Title = $NotifLocale.local.outputs.output[4].title -f $($app.Name)
|
||||||
$Message = $NotifLocal.local.outputs.output[4].message
|
$Message = $NotifLocale.local.outputs.output[4].message
|
||||||
$MessageType = "error"
|
$MessageType = "error"
|
||||||
$Balise = $($app.Name)
|
$Balise = $($app.Name)
|
||||||
Start-NotifTask $Title $Message $MessageType $Balise
|
Start-NotifTask $Title $Message $MessageType $Balise
|
||||||
|
@ -296,8 +296,8 @@ if ($ping){
|
||||||
else{
|
else{
|
||||||
Write-Log "Timeout. No internet connection !" "Red"
|
Write-Log "Timeout. No internet connection !" "Red"
|
||||||
#Send Notif
|
#Send Notif
|
||||||
$Title = $NotifLocal.local.outputs.output[1].title
|
$Title = $NotifLocale.local.outputs.output[1].title
|
||||||
$Message = $NotifLocal.local.outputs.output[1].message
|
$Message = $NotifLocale.local.outputs.output[1].message
|
||||||
$MessageType = "error"
|
$MessageType = "error"
|
||||||
$Balise = "connection"
|
$Balise = "connection"
|
||||||
Start-NotifTask $Title $Message $MessageType $Balise
|
Start-NotifTask $Title $Message $MessageType $Balise
|
||||||
|
|
Loading…
Reference in New Issue