minor changes

pull/2/head
Romain 2022-01-27 21:56:45 +01:00 committed by GitHub
parent b4adb584dd
commit b2068b37ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 26 deletions

View File

@ -1,7 +1,7 @@
#Send Notif Script #Send Notif Script
#get xml notif config #get xml notif config
[xml]$NotifConf = Get-Content "C:\ProgramData\winget-update\notif.xml" -Encoding UTF8 -ErrorAction SilentlyContinue [xml]$NotifConf = Get-Content "$env:ProgramData\winget-update\notif.xml" -Encoding UTF8 -ErrorAction SilentlyContinue
if (!($NotifConf)) {break} if (!($NotifConf)) {break}
#Load Assemblies #Load Assemblies

View File

@ -1,4 +1,4 @@
### FUNCTIONS ### <# FUNCTIONS #>
function Init { function Init {
#Var #Var
@ -62,7 +62,7 @@ function Start-NotifTask ($Title,$Message,$MessageType,$Balise) {
"@ "@
#Save XML File #Save XML File
$ToastTemplateLocation = "C:\ProgramData\winget-update\" $ToastTemplateLocation = "$env:ProgramData\winget-update\"
if (!(Test-Path $ToastTemplateLocation)){ if (!(Test-Path $ToastTemplateLocation)){
New-Item -ItemType Directory -Force -Path $ToastTemplateLocation New-Item -ItemType Directory -Force -Path $ToastTemplateLocation
} }
@ -101,15 +101,15 @@ function Test-Network {
Start-Sleep 10 Start-Sleep 10
$timeout += 10 $timeout += 10
Write-Log "Checking internet connection. $($timeout)s." "Yellow" Write-Log "Checking internet connection. $($timeout)s." "Yellow"
}
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" if ($timeout -eq 300){
$Title = $NotifLocale.local.outputs.output[0].title Write-Log "Notify 'No connection'" "Yellow"
$Message = $NotifLocale.local.outputs.output[0].message $Title = $NotifLocale.local.outputs.output[0].title
$MessageType = "warning" $Message = $NotifLocale.local.outputs.output[0].message
$Balise = "connection" $MessageType = "warning"
Start-NotifTask $Title $Message $MessageType $Balise $Balise = "connection"
Start-NotifTask $Title $Message $MessageType $Balise
}
} }
} }
Write-Log "Timeout. No internet connection !" "Red" Write-Log "Timeout. No internet connection !" "Red"
@ -207,16 +207,13 @@ function Get-ExcludedApps{
} }
<# MAIN #>
### MAIN ###
#Run initialisation #Run initialisation
Init Init
#Check network connectivity #Check network connectivity
$ping = Test-Network if (Test-Network){
if ($ping){
#Get exclude apps list #Get exclude apps list
$toSkip = Get-ExcludedApps $toSkip = Get-ExcludedApps
@ -249,17 +246,10 @@ if ($ping){
$Balise = $($app.Name) $Balise = $($app.Name)
Start-NotifTask $Title $Message $MessageType $Balise Start-NotifTask $Title $Message $MessageType $Balise
#Install update
$Log = "#--- Winget - $($app.Name) Upgrade Starts ---"
$Log | Write-host -ForegroundColor Gray
$Log | out-file -filepath $LogFile -Append
#Winget upgrade #Winget upgrade
Write-Log "------ Winget - $($app.Name) Upgrade Starts ------" "Gray"
& $upgradecmd upgrade -e --id $($app.Id) --accept-package-agreements --accept-source-agreements -h & $upgradecmd upgrade -e --id $($app.Id) --accept-package-agreements --accept-source-agreements -h
Write-Log "----- Winget - $($app.Name) Upgrade Finished -----" "Gray"
$Log = "#--- Winget - $($app.Name) Upgrade Finished ---"
$Log | Write-host -ForegroundColor Gray
$Log | out-file -filepath $LogFile -Append
#Check installed version #Check installed version
$checkoutdated = Get-WingetOutdated $checkoutdated = Get-WingetOutdated
@ -311,4 +301,4 @@ if ($ping){
#End #End
Write-Log "End of process!" "Cyan" Write-Log "End of process!" "Cyan"
Sleep 3 Sleep 3