diff --git a/Winget-AutoUpdate/User-Run.ps1 b/Winget-AutoUpdate/User-Run.ps1 index 078c960..5ec50a8 100644 --- a/Winget-AutoUpdate/User-Run.ps1 +++ b/Winget-AutoUpdate/User-Run.ps1 @@ -38,15 +38,16 @@ $Script:WorkingDir = $PSScriptRoot . $WorkingDir\functions\Get-NotifLocale.ps1 . $WorkingDir\functions\Start-NotifTask.ps1 +#Get Toast Locale function +Get-NotifLocale + #Set common variables $OnClickAction = "$WorkingDir\logs\updates.log" +$Button1Text = $NotifLocale.local.outputs.output[11].message $Title = "Winget-AutoUpdate (WAU)" $Balise = "Winget-AutoUpdate (WAU)" $UserRun = $True -#Get Toast Locale function -Get-NotifLocale - if ($Logs) { if ((Test-Path "$WorkingDir\logs\updates.log")) { Invoke-Item "$WorkingDir\logs\updates.log" @@ -55,7 +56,7 @@ if ($Logs) { #Not available yet $Message = $NotifLocale.local.outputs.output[5].message $MessageType = "warning" - Start-NotifTask $Title $Message $MessageType $Balise + Start-NotifTask -Message $Message -MessageType $MessageType } } elseif ($Help) { @@ -67,7 +68,7 @@ else { if (Test-WAUisRunning) { $Message = $NotifLocale.local.outputs.output[8].message $MessageType = "warning" - Start-NotifTask $Title $Message $MessageType $Balise $OnClickAction + Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss break } #Run scheduled task @@ -75,19 +76,19 @@ else { #Starting check - Send notification $Message = $NotifLocale.local.outputs.output[6].message $MessageType = "info" - Start-NotifTask $Title $Message $MessageType $Balise $OnClickAction + Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss #Sleep until the task is done While (Test-WAUisRunning) { Start-Sleep 3 } $Message = $NotifLocale.local.outputs.output[9].message $MessageType = "success" - Start-NotifTask $Title $Message $MessageType $Balise $OnClickAction + Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss } catch { #Check failed - Just send notification $Message = $NotifLocale.local.outputs.output[7].message $MessageType = "error" - Start-NotifTask $Title $Message $MessageType $Balise + Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss } } diff --git a/Winget-AutoUpdate/WAU-Uninstall.ps1 b/Winget-AutoUpdate/WAU-Uninstall.ps1 index d3f99d6..7590e47 100644 --- a/Winget-AutoUpdate/WAU-Uninstall.ps1 +++ b/Winget-AutoUpdate/WAU-Uninstall.ps1 @@ -1,6 +1,6 @@ <# .SYNOPSIS -Uninstall Winget-AutoUpdate +Uninstall Winget-AutoUpdate .DESCRIPTION Uninstall Winget-AutoUpdate (DEFAULT: clean old install) @@ -36,7 +36,7 @@ try { Write-host "Uninstalling WAU..." -ForegroundColor Yellow #Get registry install location $InstallLocation = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocation - + #Check if installed location exists and delete if (Test-Path ($InstallLocation)) { @@ -49,7 +49,7 @@ try { } Get-ScheduledTask -TaskName "Winget-AutoUpdate" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False Get-ScheduledTask -TaskName "Winget-AutoUpdate-Notify" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False - Get-ScheduledTask -TaskName "Winget-AutoUpdate-UserContext" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False + Get-ScheduledTask -TaskName "Winget-AutoUpdate-UserContext" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False & reg delete "HKCR\AppUserModelId\Windows.SystemToast.Winget.Notification" /f | Out-Null & reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" /f | Out-Null if (Test-Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate") { @@ -63,7 +63,7 @@ try { if ((Test-Path "${env:Public}\Desktop\WAU - Check for updated Apps.lnk")) { Remove-Item -Path "${env:Public}\Desktop\WAU - Check for updated Apps.lnk" -Force | Out-Null } - + Write-host "Uninstallation succeeded!" -ForegroundColor Green } else { diff --git a/Winget-AutoUpdate/Winget-Notify.ps1 b/Winget-AutoUpdate/Winget-Notify.ps1 index 6531226..d4a90c2 100644 --- a/Winget-AutoUpdate/Winget-Notify.ps1 +++ b/Winget-AutoUpdate/Winget-Notify.ps1 @@ -10,14 +10,14 @@ if (!($NotifConf)) { #Load Assemblies [Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null [Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null - + #Prepare XML $ToastXml = [Windows.Data.Xml.Dom.XmlDocument]::New() $ToastXml.LoadXml($NotifConf.OuterXml) #Specify Launcher App ID $LauncherID = "Windows.SystemToast.Winget.Notification" - + #Prepare and Create Toast $ToastMessage = [Windows.UI.Notifications.ToastNotification]::New($ToastXML) $ToastMessage.Tag = $NotifConf.toast.tag diff --git a/Winget-AutoUpdate/Winget-Upgrade.ps1 b/Winget-AutoUpdate/Winget-Upgrade.ps1 index f584bbf..0852a31 100644 --- a/Winget-AutoUpdate/Winget-Upgrade.ps1 +++ b/Winget-AutoUpdate/Winget-Upgrade.ps1 @@ -44,7 +44,7 @@ Write-Log "Notification Level: $($WAUConfig.WAU_NotificationLevel). Notification if (Test-Network) { #Check if Winget is installed and get Winget cmd $TestWinget = Get-WingetCmd - + if ($TestWinget) { #Get Current Version $WAUCurrentVersion = $WAUConfig.DisplayVersion @@ -111,7 +111,7 @@ if (Test-Network) { $Log | Write-host $Log | out-file -filepath $LogFile -Append } - + #Count good update installations $Script:InstallOK = 0 @@ -156,7 +156,7 @@ if (Test-Network) { } } } - + if ($InstallOK -gt 0) { Write-Log "$InstallOK apps updated ! No more update." "Green" } diff --git a/Winget-AutoUpdate/functions/Add-ScopeMachine.ps1 b/Winget-AutoUpdate/functions/Add-ScopeMachine.ps1 index 81ef5da..dfdb145 100644 --- a/Winget-AutoUpdate/functions/Add-ScopeMachine.ps1 +++ b/Winget-AutoUpdate/functions/Add-ScopeMachine.ps1 @@ -17,4 +17,4 @@ function Add-ScopeMachine ($SettingsPath) { } $ConfigFile | ConvertTo-Json | Out-File $SettingsPath -Encoding utf8 -Force -} \ No newline at end of file +} diff --git a/Winget-AutoUpdate/functions/Get-AppInfo.ps1 b/Winget-AutoUpdate/functions/Get-AppInfo.ps1 index 38937e4..62a45f2 100644 --- a/Winget-AutoUpdate/functions/Get-AppInfo.ps1 +++ b/Winget-AutoUpdate/functions/Get-AppInfo.ps1 @@ -9,4 +9,4 @@ Function Get-AppInfo ($AppID) { #Return Release Note return $ReleaseNote -} \ No newline at end of file +} diff --git a/Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 b/Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 index 04b3ef8..ad77101 100644 --- a/Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 +++ b/Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 @@ -7,5 +7,5 @@ function Get-ExcludedApps { return (Get-Content -Path "$WorkingDir\excluded_apps.txt").Trim() | Where-Object { $_.length -gt 0 } } - + } diff --git a/Winget-AutoUpdate/functions/Get-IncludedApps.ps1 b/Winget-AutoUpdate/functions/Get-IncludedApps.ps1 index c930203..e767953 100644 --- a/Winget-AutoUpdate/functions/Get-IncludedApps.ps1 +++ b/Winget-AutoUpdate/functions/Get-IncludedApps.ps1 @@ -5,7 +5,7 @@ function Get-IncludedApps { if (Test-Path "$WorkingDir\included_apps.txt") { return (Get-Content -Path "$WorkingDir\included_apps.txt").Trim() | Where-Object { $_.length -gt 0 } - + } } diff --git a/Winget-AutoUpdate/functions/Get-NotifLocale.ps1 b/Winget-AutoUpdate/functions/Get-NotifLocale.ps1 index 24b75e0..fb481e7 100644 --- a/Winget-AutoUpdate/functions/Get-NotifLocale.ps1 +++ b/Winget-AutoUpdate/functions/Get-NotifLocale.ps1 @@ -1,12 +1,12 @@ #Function to get locale file for Notification. Function Get-NotifLocale { - + #Get OS locale $OSLocale = (Get-Culture).Parent #Test if OS locale notif file exists - $TestOSLocalPath = "$WorkingDir\locale\$($OSLocale.Name).xml" + $TestOSLocalPath = "$WorkingDir\locale\$($OSLocale.Name).xml" #Set OS Local if file exists if (Test-Path $TestOSLocalPath) { @@ -25,4 +25,4 @@ Function Get-NotifLocale { #Rerturn langague display name Return $LocaleDisplayName -} \ No newline at end of file +} diff --git a/Winget-AutoUpdate/functions/Get-WAUAvailableVersion.ps1 b/Winget-AutoUpdate/functions/Get-WAUAvailableVersion.ps1 index e8bd42d..80c5fd8 100644 --- a/Winget-AutoUpdate/functions/Get-WAUAvailableVersion.ps1 +++ b/Winget-AutoUpdate/functions/Get-WAUAvailableVersion.ps1 @@ -4,21 +4,21 @@ function Get-WAUAvailableVersion { #Get Github latest version if ($WAUConfig.WAU_UpdatePrerelease -eq 1) { - + #Log Write-log "WAU AutoUpdate Pre-release versions is Enabled" "Cyan" - + #Get latest pre-release info $WAUurl = 'https://api.github.com/repos/Romanitho/Winget-AutoUpdate/releases' - + } else { - + #Get latest stable info $WAUurl = 'https://api.github.com/repos/Romanitho/Winget-AutoUpdate/releases/latest' - + } return ((Invoke-WebRequest $WAUurl -UseBasicParsing | ConvertFrom-Json)[0].tag_name).Replace("v", "") -} \ No newline at end of file +} diff --git a/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 b/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 index adc3165..031b437 100644 --- a/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 +++ b/Winget-AutoUpdate/functions/Get-WingetOutdatedApps.ps1 @@ -25,8 +25,8 @@ function Get-WingetOutdatedApps { while (-not $lines[$fl].StartsWith("-----")) { $fl++ } - - #Get header line + + #Get header line $fl = $fl - 1 #Get header titles @@ -59,4 +59,4 @@ function Get-WingetOutdatedApps { } return $upgradeList | Sort-Object { Get-Random } -} \ No newline at end of file +} diff --git a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 index d0b1848..9d09782 100644 --- a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 +++ b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 @@ -1,7 +1,7 @@ #Function to make actions post WAU update function Invoke-PostUpdateActions { - + #log Write-Log "Running Post Update actions..." "yellow" @@ -15,7 +15,7 @@ function Invoke-PostUpdateActions { #log Write-Log "-> Winget sources reseted." "green" } - + #Create WAU Regkey if not present $regPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" if (!(test-path $regPath)) { @@ -42,7 +42,7 @@ function Invoke-PostUpdateActions { #log Write-Log "-> Notification level setting was missing. Fixed with 'Full' option." } - + #Convert about.xml if exists (previous WAU versions) to reg $WAUAboutPath = "$WorkingDir\config\about.xml" if (test-path $WAUAboutPath) { @@ -83,7 +83,7 @@ function Invoke-PostUpdateActions { foreach ($FileName in $FileNames) { if (Test-Path $FileName) { Remove-Item $FileName -Force -Confirm:$false - + #log Write-Log "-> $FileName removed." "green" } @@ -97,5 +97,5 @@ function Invoke-PostUpdateActions { #log Write-Log "Post Update actions finished" "green" - -} \ No newline at end of file + +} diff --git a/Winget-AutoUpdate/functions/Start-Init.ps1 b/Winget-AutoUpdate/functions/Start-Init.ps1 index 7d79a44..280ecbb 100644 --- a/Winget-AutoUpdate/functions/Start-Init.ps1 +++ b/Winget-AutoUpdate/functions/Start-Init.ps1 @@ -11,7 +11,7 @@ function Start-Init { #Logs initialisation $Script:LogFile = "$WorkingDir\logs\updates.log" - + if (!(Test-Path $LogFile)) { #Create file if doesn't exist New-Item -ItemType File -Path $LogFile -Force @@ -30,4 +30,4 @@ function Start-Init { #Log file $Log | out-file -filepath $LogFile -Append -} \ No newline at end of file +} diff --git a/Winget-AutoUpdate/functions/Start-NotifTask.ps1 b/Winget-AutoUpdate/functions/Start-NotifTask.ps1 index 22c74df..668f387 100644 --- a/Winget-AutoUpdate/functions/Start-NotifTask.ps1 +++ b/Winget-AutoUpdate/functions/Start-NotifTask.ps1 @@ -1,27 +1,135 @@ #Function to send notifications to user -function Start-NotifTask ($Title, $Message, $MessageType, $Balise, $OnClickAction) { +function Start-NotifTask { + + param( + [String]$Title = "Winget-AutoUpdate", + [String]$Message, + [String]$MessageType, + [String]$Balise = "WAU", + [String]$OnClickAction, + [String]$Body, + [String]$Button1Text, + [String]$Button1Action, + [Switch]$ButtonDismiss = $false + ) if (($WAUConfig.WAU_NotificationLevel -eq "Full") -or ($WAUConfig.WAU_NotificationLevel -eq "SuccessOnly" -and $MessageType -eq "Success") -or ($UserRun)) { - #Prepare OnClickAction (if set) - if ($OnClickAction) { - $ToastOnClickAction = "activationType='protocol' launch='$OnClickAction'" + # XML Toast template creation + [xml]$ToastTemplate = New-Object system.Xml.XmlDocument + $ToastTemplate.LoadXml("") + + # Creation of visual node + $XMLvisual = $ToastTemplate.CreateElement("visual") + + # Creation of a binding node + $XMLbinding = $ToastTemplate.CreateElement("binding") + $XMLvisual.AppendChild($XMLbinding) | Out-Null + $XMLbindingAtt1 = ($ToastTemplate.CreateAttribute("template")) + $XMLbindingAtt1.Value = "ToastGeneric" + $XMLbinding.Attributes.Append($XMLbindingAtt1) | Out-Null + + $XMLimagepath = "$WorkingDir\icons\$MessageType.png" + if (Test-Path $XMLimagepath){ + # Creation of a image node + $XMLimage = $ToastTemplate.CreateElement("image") + $XMLbinding.AppendChild($XMLimage) | Out-Null + $XMLimageAtt1 = $ToastTemplate.CreateAttribute("placement") + $XMLimageAtt1.Value = "appLogoOverride" + $XMLimage.Attributes.Append($XMLimageAtt1) | Out-Null + $XMLimageAtt2 = $ToastTemplate.CreateAttribute("src") + $XMLimageAtt2.Value = "$WorkingDir\icons\$MessageType.png" + $XMLimage.Attributes.Append($XMLimageAtt2) | Out-Null } - #Add XML variables - [xml]$ToastTemplate = @" - - - - $Title - $Message - - - - $Balise - -"@ + if ($Title){ + # Creation of a text node + $XMLtitle = $ToastTemplate.CreateElement("text") + $XMLtitleText = $ToastTemplate.CreateTextNode($Title) + $XMLtitle.AppendChild($XMLtitleText) | Out-Null + $XMLbinding.AppendChild($XMLtitle) | Out-Null + } + + if ($Message){ + # Creation of a text node + $XMLtext = $ToastTemplate.CreateElement("text") + $XMLtextText = $ToastTemplate.CreateTextNode($Message) + $XMLtext.AppendChild($XMLtextText) | Out-Null + $XMLbinding.AppendChild($XMLtext) | Out-Null + } + + if ($Body){ + # Creation of a group node + $XMLgroup = $ToastTemplate.CreateElement("group") + $XMLbinding.AppendChild($XMLgroup) | Out-Null + + # Creation of a subgroup node + $XMLsubgroup = $ToastTemplate.CreateElement("subgroup") + $XMLgroup.AppendChild($XMLsubgroup) | Out-Null + + # Creation of a text node + $XMLcontent = $ToastTemplate.CreateElement("text") + $XMLcontentText = $ToastTemplate.CreateTextNode($Body) + $XMLcontent.AppendChild($XMLcontentText) | Out-Null + $XMLsubgroup.AppendChild($XMLcontent) | Out-Null + $XMLcontentAtt1 = $ToastTemplate.CreateAttribute("hint-style") + $XMLcontentAtt1.Value = "body" + $XMLcontent.Attributes.Append($XMLcontentAtt1) | Out-Null + $XMLcontentAtt2 = $ToastTemplate.CreateAttribute("hint-wrap") + $XMLcontentAtt2.Value = "true" + $XMLcontent.Attributes.Append($XMLcontentAtt2) | Out-Null + } + + # Creation of actions node + $XMLactions = $ToastTemplate.CreateElement("actions") + + if ($Button1Text) { + # Creation of action node + $XMLaction = $ToastTemplate.CreateElement("action") + $XMLactions.AppendChild($XMLaction) | Out-Null + $XMLactionAtt1 = $ToastTemplate.CreateAttribute("content") + $XMLactionAtt1.Value = $Button1Text + $XMLaction.Attributes.Append($XMLactionAtt1) | Out-Null + if ($Button1Action){ + $XMLactionAtt2 = $ToastTemplate.CreateAttribute("arguments") + $XMLactionAtt2.Value = $Button1Action + $XMLaction.Attributes.Append($XMLactionAtt2) | Out-Null + $XMLactionAtt3 = $ToastTemplate.CreateAttribute("activationType") + $XMLactionAtt3.Value = "Protocol" + $XMLaction.Attributes.Append($XMLactionAtt3) | Out-Null + } + } + + if ($ButtonDismiss) { + # Creation of action node + $XMLaction = $ToastTemplate.CreateElement("action") + $XMLactions.AppendChild($XMLaction) | Out-Null + $XMLactionAtt1 = $ToastTemplate.CreateAttribute("content") + $XMLactionAtt1.Value = "" + $XMLaction.Attributes.Append($XMLactionAtt1) | Out-Null + $XMLactionAtt2 = $ToastTemplate.CreateAttribute("arguments") + $XMLactionAtt2.Value = "dismiss" + $XMLaction.Attributes.Append($XMLactionAtt2) | Out-Null + $XMLactionAtt3 = $ToastTemplate.CreateAttribute("activationType") + $XMLactionAtt3.Value = "system" + $XMLaction.Attributes.Append($XMLactionAtt3) | Out-Null + } + + # Creation of tag node + $XMLtag = $ToastTemplate.CreateElement("tag") + $XMLtagText = $ToastTemplate.CreateTextNode($Balise) + $XMLtag.AppendChild($XMLtagText) | Out-Null + + # Add the visual node to the xml + $ToastTemplate.LastChild.AppendChild($XMLvisual) | Out-Null + $ToastTemplate.LastChild.AppendChild($XMLactions) | Out-Null + $ToastTemplate.LastChild.AppendChild($XMLtag) | Out-Null + + if ($OnClickAction){ + $ToastTemplate.toast.SetAttribute("activationType", "Protocol") | Out-Null + $ToastTemplate.toast.SetAttribute("launch", $OnClickAction) | Out-Null + } #if not "Interactive" user, run as system if ($IsSystem) { @@ -35,7 +143,7 @@ function Start-NotifTask ($Title, $Message, $MessageType, $Balise, $OnClickActio #Run Notify scheduled task to notify conneted users Get-ScheduledTask -TaskName "Winget-AutoUpdate-Notify" -ErrorAction SilentlyContinue | Start-ScheduledTask -ErrorAction SilentlyContinue - + } #else, run as connected user else { @@ -50,7 +158,7 @@ function Start-NotifTask ($Title, $Message, $MessageType, $Balise, $OnClickActio #Specify Launcher App ID $LauncherID = "Windows.SystemToast.Winget.Notification" - + #Prepare and Create Toast $ToastMessage = [Windows.UI.Notifications.ToastNotification]::New($ToastXml) $ToastMessage.Tag = $ToastTemplate.toast.tag @@ -63,4 +171,4 @@ function Start-NotifTask ($Title, $Message, $MessageType, $Balise, $OnClickActio } -} \ No newline at end of file +} diff --git a/Winget-AutoUpdate/functions/Test-Network.ps1 b/Winget-AutoUpdate/functions/Test-Network.ps1 index 9d326e3..a726373 100644 --- a/Winget-AutoUpdate/functions/Test-Network.ps1 +++ b/Winget-AutoUpdate/functions/Test-Network.ps1 @@ -55,12 +55,15 @@ function Test-Network { #Send Warning Notif if no connection for 5 min if ($timeout -eq 300) { + #Log Write-Log "Notify 'No connection' sent." "Yellow" + + #Notif $Title = $NotifLocale.local.outputs.output[0].title $Message = $NotifLocale.local.outputs.output[0].message $MessageType = "warning" - $Balise = "connection" - Start-NotifTask $Title $Message $MessageType $Balise + $Balise = "Connection" + Start-NotifTask -Title $Title -Message $Message -MessageType $MessageType -Balise $Balise } } @@ -69,11 +72,14 @@ function Test-Network { #Send Timeout Notif if no connection for 30 min Write-Log "Timeout. No internet connection !" "Red" + + #Notif $Title = $NotifLocale.local.outputs.output[1].title $Message = $NotifLocale.local.outputs.output[1].message $MessageType = "error" - $Balise = "connection" - Start-NotifTask $Title $Message $MessageType $Balise + $Balise = "Connection" + Start-NotifTask -Title $Title -Message $Message -MessageType $MessageType -Balise $Balise + return $false } diff --git a/Winget-AutoUpdate/functions/Test-PendingReboot.ps1 b/Winget-AutoUpdate/functions/Test-PendingReboot.ps1 index 1f80e74..55bc72f 100644 --- a/Winget-AutoUpdate/functions/Test-PendingReboot.ps1 +++ b/Winget-AutoUpdate/functions/Test-PendingReboot.ps1 @@ -1,23 +1,23 @@ #Function to check if there's a Pending Reboot function Test-PendingReboot { - + $Computer = $env:COMPUTERNAME $PendingReboot = $false - + $HKLM = [UInt32] "0x80000002" $WMI_Reg = [WMIClass] "\\$Computer\root\default:StdRegProv" - + if ($WMI_Reg) { if (($WMI_Reg.EnumKey($HKLM, "SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\")).sNames -contains 'RebootPending') { $PendingReboot = $true } if (($WMI_Reg.EnumKey($HKLM, "SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\")).sNames -contains 'RebootRequired') { $PendingReboot = $true } - + #Checking for SCCM namespace $SCCM_Namespace = Get-WmiObject -Namespace ROOT\CCM\ClientSDK -List -ComputerName $Computer -ErrorAction Ignore if ($SCCM_Namespace) { if (([WmiClass]"\\$Computer\ROOT\CCM\ClientSDK:CCM_ClientUtilities").DetermineIfRebootPending().RebootPending -eq $true) { $PendingReboot = $true } } - + } return $PendingReboot diff --git a/Winget-AutoUpdate/functions/Update-App.ps1 b/Winget-AutoUpdate/functions/Update-App.ps1 index 41e2728..efedd64 100644 --- a/Winget-AutoUpdate/functions/Update-App.ps1 +++ b/Winget-AutoUpdate/functions/Update-App.ps1 @@ -3,7 +3,10 @@ Function Update-App ($app) { #Get App Info - $OnClickAction = Get-AppInfo $app.Id + $ReleaseNoteURL = Get-AppInfo $app.Id + if ($ReleaseNoteURL){ + $Button1Text = $NotifLocale.local.outputs.output[10].message + } #Send available update notification Write-Log "Updating $($app.Name) from $($app.Version) to $($app.AvailableVersion)..." "Cyan" @@ -11,11 +14,11 @@ Function Update-App ($app) { $Message = $NotifLocale.local.outputs.output[2].message -f $($app.Version), $($app.AvailableVersion) $MessageType = "info" $Balise = $($app.Name) - Start-NotifTask $Title $Message $MessageType $Balise $OnClickAction + Start-NotifTask -Title $Title -Message $Message -MessageType $MessageType -Balise $Balise -Button1Action $ReleaseNoteURL -Button1Text $Button1Text #Winget upgrade Write-Log "########## WINGET UPGRADE PROCESS STARTS FOR APPLICATION ID '$($App.Id)' ##########" "Gray" - + #Run Winget Upgrade command Write-Log "-> Running: Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements -h" & $Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append @@ -28,7 +31,7 @@ Function Update-App ($app) { $FailedToUpgrade = $false foreach ($CheckApp in $CheckOutdated) { if ($($CheckApp.Id) -eq $($app.Id)) { - + #Upgrade failed! #Test for a Pending Reboot (Component Based Servicing/WindowsUpdate/CCM_ClientUtilities) $PendingReboot = Test-PendingReboot @@ -37,7 +40,7 @@ Function Update-App ($app) { $FailedToUpgrade = $true break } - + #If app failed to upgrade, run Install command Write-Log "-> An upgrade for $($app.Name) failed, now trying an install instead..." "Yellow" Write-Log "-> Running: Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements -h" @@ -71,36 +74,36 @@ Function Update-App ($app) { } } - Write-Log "########## WINGET UPGRADE PROCESS FINISHED FOR APPLICATION ID '$($App.Id)' ##########" "Gray" + Write-Log "########## WINGET UPGRADE PROCESS FINISHED FOR APPLICATION ID '$($App.Id)' ##########" "Gray" #Notify installation - if ($FailedToUpgrade -eq $false) { + if ($FailedToUpgrade -eq $false) { #Send success updated app notification Write-Log "$($app.Name) updated to $($app.AvailableVersion) !" "Green" - + #Send Notif $Title = $NotifLocale.local.outputs.output[3].title -f $($app.Name) $Message = $NotifLocale.local.outputs.output[3].message -f $($app.AvailableVersion) $MessageType = "success" $Balise = $($app.Name) - Start-NotifTask $Title $Message $MessageType $Balise $OnClickAction + Start-NotifTask -Title $Title -Message $Message -MessageType $MessageType -Balise $Balise -Button1Action $ReleaseNoteURL -Button1Text $Button1Text $Script:InstallOK += 1 - + } else { #Send failed updated app notification Write-Log "$($app.Name) update failed." "Red" - + #Send Notif $Title = $NotifLocale.local.outputs.output[4].title -f $($app.Name) $Message = $NotifLocale.local.outputs.output[4].message $MessageType = "error" $Balise = $($app.Name) - Start-NotifTask $Title $Message $MessageType $Balise $OnClickAction - + Start-NotifTask -Title $Title -Message $Message -MessageType $MessageType -Balise $Balise -Button1Action $ReleaseNoteURL -Button1Text $Button1Text + } } \ No newline at end of file diff --git a/Winget-AutoUpdate/functions/Update-WAU.ps1 b/Winget-AutoUpdate/functions/Update-WAU.ps1 index 25e43bd..25a158f 100644 --- a/Winget-AutoUpdate/functions/Update-WAU.ps1 +++ b/Winget-AutoUpdate/functions/Update-WAU.ps1 @@ -3,22 +3,22 @@ function Update-WAU { $OnClickAction = "https://github.com/Romanitho/Winget-AutoUpdate/releases" + $Button1Text = $NotifLocale.local.outputs.output[10].message #Send available update notification $Title = $NotifLocale.local.outputs.output[2].title -f "Winget-AutoUpdate" $Message = $NotifLocale.local.outputs.output[2].message -f $WAUCurrentVersion, $WAUAvailableVersion $MessageType = "info" - $Balise = "Winget-AutoUpdate" - Start-NotifTask $Title $Message $MessageType $Balise $OnClickAction + Start-NotifTask -Title $Title -Message $Message -MessageType $MessageType -Button1Action $OnClickAction -Button1Text $Button1Text #Run WAU update try { - #Force to create a zip file + #Force to create a zip file $ZipFile = "$WorkingDir\WAU_update.zip" New-Item $ZipFile -ItemType File -Force | Out-Null - #Download the zip + #Download the zip Write-Log "Downloading the GitHub Repository version $WAUAvailableVersion" "Cyan" Invoke-RestMethod -Uri "https://github.com/Romanitho/Winget-AutoUpdate/archive/refs/tags/v$($WAUAvailableVersion).zip/" -OutFile $ZipFile @@ -27,14 +27,14 @@ function Update-WAU { $location = "$WorkingDir\WAU_update" Expand-Archive -Path $ZipFile -DestinationPath $location -Force Get-ChildItem -Path $location -Recurse | Unblock-File - + #Update scritps Write-Log "Updating WAU" "Yellow" $TempPath = (Resolve-Path "$location\*\Winget-AutoUpdate\")[0].Path if ($TempPath) { Copy-Item -Path "$TempPath\*" -Destination "$WorkingDir\" -Exclude "icons" -Recurse -Force } - + #Remove update zip file and update temp folder Write-Log "Done. Cleaning temp files" "Cyan" Remove-Item -Path $ZipFile -Force -ErrorAction SilentlyContinue @@ -53,8 +53,7 @@ function Update-WAU { $Title = $NotifLocale.local.outputs.output[3].title -f "Winget-AutoUpdate" $Message = $NotifLocale.local.outputs.output[3].message -f $WAUAvailableVersion $MessageType = "success" - $Balise = "Winget-AutoUpdate" - Start-NotifTask $Title $Message $MessageType $Balise $OnClickAction + Start-NotifTask -Title $Title -Message $Message -MessageType $MessageType -Button1Action $OnClickAction -Button1Text $Button1Text #Rerun with newer version Write-Log "Re-run WAU" @@ -65,15 +64,14 @@ function Update-WAU { } catch { - + #Send Error Notif $Title = $NotifLocale.local.outputs.output[4].title -f "Winget-AutoUpdate" $Message = $NotifLocale.local.outputs.output[4].message $MessageType = "error" - $Balise = "Winget-AutoUpdate" - Start-NotifTask $Title $Message $MessageType $Balise $OnClickAction + Start-NotifTask -Title $Title -Message $Message -MessageType $MessageType -Button1Action $OnClickAction -Button1Text $Button1Text Write-Log "WAU Update failed" "Red" - + } } \ No newline at end of file diff --git a/Winget-AutoUpdate/functions/Write-Log.ps1 b/Winget-AutoUpdate/functions/Write-Log.ps1 index e4fd1ce..aa30cb2 100644 --- a/Winget-AutoUpdate/functions/Write-Log.ps1 +++ b/Winget-AutoUpdate/functions/Write-Log.ps1 @@ -1,7 +1,7 @@ #Write Log Function function Write-Log ($LogMsg, $LogColor = "White") { - + #Get log $Log = "$(Get-Date -UFormat "%T") - $LogMsg" @@ -11,4 +11,4 @@ function Write-Log ($LogMsg, $LogColor = "White") { #Write log to file $Log | Out-File -FilePath $LogFile -Append -} \ No newline at end of file +} diff --git a/Winget-AutoUpdate/locale/de.xml b/Winget-AutoUpdate/locale/de.xml index 02a0070..bb95779 100644 --- a/Winget-AutoUpdate/locale/de.xml +++ b/Winget-AutoUpdate/locale/de.xml @@ -49,6 +49,13 @@ Die manuelle suche nach Updates wurde abgeschlossen. + + + See changelog + + + + Open log file diff --git a/Winget-AutoUpdate/locale/en.xml b/Winget-AutoUpdate/locale/en.xml index 66bc000..6f927b0 100644 --- a/Winget-AutoUpdate/locale/en.xml +++ b/Winget-AutoUpdate/locale/en.xml @@ -50,5 +50,13 @@ Manual check for updated apps completed... + + + See changelog + + + + Open log file + diff --git a/Winget-AutoUpdate/locale/es.xml b/Winget-AutoUpdate/locale/es.xml index d537ea0..6942ab1 100644 --- a/Winget-AutoUpdate/locale/es.xml +++ b/Winget-AutoUpdate/locale/es.xml @@ -50,5 +50,13 @@ Manual check for updated apps completed... + + + See changelog + + + + Open log file + diff --git a/Winget-AutoUpdate/locale/fi.xml b/Winget-AutoUpdate/locale/fi.xml index 8204fd0..33e7d59 100644 --- a/Winget-AutoUpdate/locale/fi.xml +++ b/Winget-AutoUpdate/locale/fi.xml @@ -50,5 +50,13 @@ Manual check for updated apps completed... + + + See changelog + + + + Open log file + diff --git a/Winget-AutoUpdate/locale/fr.xml b/Winget-AutoUpdate/locale/fr.xml index 3b0e445..36e845c 100644 --- a/Winget-AutoUpdate/locale/fr.xml +++ b/Winget-AutoUpdate/locale/fr.xml @@ -50,5 +50,13 @@ Recherche de mises à jour terminée. + + + Consulter le journal des modifications + + + + Ouvrir le fichier log + diff --git a/Winget-AutoUpdate/locale/hu.xml b/Winget-AutoUpdate/locale/hu.xml index f0afdc0..1b7cc55 100644 --- a/Winget-AutoUpdate/locale/hu.xml +++ b/Winget-AutoUpdate/locale/hu.xml @@ -50,5 +50,13 @@ A frissített alkalmazások kézi ellenőrzése befejeződött... + + + See changelog + + + + Open log file + diff --git a/Winget-AutoUpdate/locale/it.xml b/Winget-AutoUpdate/locale/it.xml index f016e00..b790c0f 100644 --- a/Winget-AutoUpdate/locale/it.xml +++ b/Winget-AutoUpdate/locale/it.xml @@ -50,5 +50,13 @@ Manual check for updated apps completed... + + + See changelog + + + + Open log file + diff --git a/Winget-AutoUpdate/locale/nl.xml b/Winget-AutoUpdate/locale/nl.xml index e77cd65..c08bfed 100644 --- a/Winget-AutoUpdate/locale/nl.xml +++ b/Winget-AutoUpdate/locale/nl.xml @@ -50,5 +50,13 @@ Manual check for updated apps completed... + + + See changelog + + + + Open log file + diff --git a/Winget-AutoUpdate/locale/pl.xml b/Winget-AutoUpdate/locale/pl.xml index 49b3c1e..5e7ca36 100644 --- a/Winget-AutoUpdate/locale/pl.xml +++ b/Winget-AutoUpdate/locale/pl.xml @@ -50,5 +50,13 @@ Manual check for updated apps completed... + + + See changelog + + + + Open log file + diff --git a/Winget-AutoUpdate/locale/sv.xml b/Winget-AutoUpdate/locale/sv.xml index 73d1c4a..24daec6 100644 --- a/Winget-AutoUpdate/locale/sv.xml +++ b/Winget-AutoUpdate/locale/sv.xml @@ -50,5 +50,13 @@ Manuell koll efter uppdaterade appar slutförd... + + + See changelog + + + + Open log file +