1- # ## FUNCTIONS ###
1+ <# FUNCTIONS #>
22
33function Init {
44 # Var
@@ -62,7 +62,7 @@ function Start-NotifTask ($Title,$Message,$MessageType,$Balise) {
6262"@
6363
6464 # Save XML File
65- $ToastTemplateLocation = " C:\ ProgramData\winget-update\"
65+ $ToastTemplateLocation = " $ env: ProgramData \winget-update\"
6666 if (! (Test-Path $ToastTemplateLocation )){
6767 New-Item - ItemType Directory - Force - Path $ToastTemplateLocation
6868 }
@@ -101,15 +101,15 @@ function Test-Network {
101101 Start-Sleep 10
102102 $timeout += 10
103103 Write-Log " Checking internet connection. $ ( $timeout ) s." " Yellow"
104- }
105- if ($timeout -eq 300 ){
106104 # Send Notif if no connection for 5 min
107- Write-Log " Notify 'No connection'" " Yellow"
108- $Title = $NotifLocale.local.outputs.output [0 ].title
109- $Message = $NotifLocale.local.outputs.output [0 ].message
110- $MessageType = " warning"
111- $Balise = " connection"
112- Start-NotifTask $Title $Message $MessageType $Balise
105+ if ($timeout -eq 300 ){
106+ Write-Log " Notify 'No connection'" " Yellow"
107+ $Title = $NotifLocale.local.outputs.output [0 ].title
108+ $Message = $NotifLocale.local.outputs.output [0 ].message
109+ $MessageType = " warning"
110+ $Balise = " connection"
111+ Start-NotifTask $Title $Message $MessageType $Balise
112+ }
113113 }
114114 }
115115 Write-Log " Timeout. No internet connection !" " Red"
@@ -207,16 +207,13 @@ function Get-ExcludedApps{
207207}
208208
209209
210-
211- # ## MAIN ###
210+ <# MAIN #>
212211
213212# Run initialisation
214213Init
215214
216215# Check network connectivity
217- $ping = Test-Network
218-
219- if ($ping ){
216+ if (Test-Network ){
220217
221218 # Get exclude apps list
222219 $toSkip = Get-ExcludedApps
@@ -249,17 +246,10 @@ if ($ping){
249246 $Balise = $ ($app.Name )
250247 Start-NotifTask $Title $Message $MessageType $Balise
251248
252- # Install update
253- $Log = " #--- Winget - $ ( $app.Name ) Upgrade Starts ---"
254- $Log | Write-host - ForegroundColor Gray
255- $Log | out-file - filepath $LogFile - Append
256-
257249 # Winget upgrade
250+ Write-Log " ------ Winget - $ ( $app.Name ) Upgrade Starts ------" " Gray"
258251 & $upgradecmd upgrade - e -- id $ ($app.Id ) -- accept- package- agreements -- accept- source- agreements - h
259-
260- $Log = " #--- Winget - $ ( $app.Name ) Upgrade Finished ---"
261- $Log | Write-host - ForegroundColor Gray
262- $Log | out-file - filepath $LogFile - Append
252+ Write-Log " ----- Winget - $ ( $app.Name ) Upgrade Finished -----" " Gray"
263253
264254 # Check installed version
265255 $checkoutdated = Get-WingetOutdated
@@ -311,4 +301,4 @@ if ($ping){
311301
312302# End
313303Write-Log " End of process!" " Cyan"
314- Sleep 3
304+ Sleep 3
0 commit comments