2525 $LocaleFile = " $WorkingDir \locale\$ ( $locale.Name ) .xml"
2626 if (Test-Path $LocaleFile ){
2727 [xml ]$Script :NotifLocale = Get-Content $LocaleFile - Encoding UTF8 - ErrorAction SilentlyContinue
28- Write-Log " Notification Langugage : $ ( $locale.Name ) "
28+ $LocaleNotif = " Notification Langugage : $ ( $locale.Name ) "
2929 }
3030 else {
3131 [xml ]$Script :NotifLocale = Get-Content $DefaultLocale - Encoding UTF8 - ErrorAction SilentlyContinue
32- Write-Log " Notification Langugage : en-US"
33- }
32+ $LocaleNotif = " Notification Langugage : en-US"
33+ }
34+ Write-Log $LocaleNotif " Cyan"
3435}
3536
3637function Write-Log ($LogMsg , $LogColor = " White" ) {
@@ -65,6 +66,7 @@ function Start-NotifTask ($Title,$Message,$MessageType,$Balise) {
6566 }
6667 $ToastTemplate.Save (" $ToastTemplateLocation \notif.xml" )
6768
69+
6870 # Send Notification to user
6971 Get-ScheduledTask - TaskName " Winget Update Notify" - ErrorAction SilentlyContinue | Start-ScheduledTask - ErrorAction SilentlyContinue
7072 # Wait for notification to display
@@ -82,9 +84,9 @@ function Test-Network {
8284 while (! $ping -and $timeout -lt 1800 ){
8385 try {
8486 Invoke-RestMethod - Uri " https://api.github.com/zen"
85- Write-Log " Coonected !" " Green"
87+ Write-Log " Connected !" " Green"
8688 $ping = $true
87- return
89+ return $ping
8890 }
8991 catch {
9092 Start-Sleep 10
@@ -146,8 +148,7 @@ function Get-WingetOutdated {
146148
147149 # Find the line that starts with "------"
148150 $fl = 0
149- while (-not $lines [$fl ].StartsWith(" -----" ))
150- {
151+ while (-not $lines [$fl ].StartsWith(" -----" )){
151152 $fl ++
152153 }
153154
@@ -165,21 +166,18 @@ function Get-WingetOutdated {
165166
166167 # Now cycle in real package and split accordingly
167168 $upgradeList = @ ()
168- For ($i = $fl + 2 ; $i -le $lines.Length ; $i ++ )
169- {
169+ For ($i = $fl + 2 ; $i -le $lines.Length ; $i ++ ){
170170 $line = $lines [$i ]
171- if ($line.Length -gt ($availableStart + 1 ) -and -not $line.StartsWith (' -' ))
172- {
173- $name = $line.Substring (0 , $idStart ).TrimEnd()
174- $id = $line.Substring ($idStart , $versionStart - $idStart ).TrimEnd()
175- $version = $line.Substring ($versionStart , $availableStart - $versionStart ).TrimEnd()
176- $available = $line.Substring ($availableStart , $sourceStart - $availableStart ).TrimEnd()
171+ if ($line.Length -gt ($sourceStart ) -and -not $line.StartsWith (' -' )){
177172 $software = [Software ]::new()
178- $software.Name = $name ;
179- $software.Id = $id ;
180- $software.Version = $version
181- $software.AvailableVersion = $available ;
182- $upgradeList += $software
173+ $software.Name = $line.Substring (0 , $idStart ).TrimEnd()
174+ $software.Id = $line.Substring ($idStart , $versionStart - $idStart ).TrimEnd()
175+ $software.Version = $line.Substring ($versionStart , $availableStart - $versionStart ).TrimEnd()
176+ $software.AvailableVersion = $line.Substring ($availableStart , $sourceStart - $availableStart ).TrimEnd()
177+ # check if Avalaible Version is > than Current Version
178+ if ([version ]$software.AvailableVersion -gt [version ]$software.Version ){
179+ $upgradeList += $software
180+ }
183181 }
184182 }
185183
0 commit comments