New things :)

pull/214/head
romanitho 2022-10-27 00:49:10 +02:00
parent f28ffed5cd
commit aec7bd2f94
30 changed files with 134 additions and 87 deletions

View File

@ -105,12 +105,12 @@ $WAUVersion = "1.15.3"
function Install-Prerequisites { function Install-Prerequisites {
Write-Host "`nChecking prerequisites..." -ForegroundColor Yellow Write-Host "`nChecking prerequisites..." -ForegroundColor Yellow
#Check if Visual C++ 2019 or 2022 installed #Check if Visual C++ 2019 or 2022 installed
$Visual2019 = "Microsoft Visual C++ 2015-2019 Redistributable*" $Visual2019 = "Microsoft Visual C++ 2015-2019 Redistributable*"
$Visual2022 = "Microsoft Visual C++ 2015-2022 Redistributable*" $Visual2022 = "Microsoft Visual C++ 2015-2022 Redistributable*"
$path = Get-Item HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object { $_.GetValue("DisplayName") -like $Visual2019 -or $_.GetValue("DisplayName") -like $Visual2022 } $path = Get-Item HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object { $_.GetValue("DisplayName") -like $Visual2019 -or $_.GetValue("DisplayName") -like $Visual2022 }
#If not installed, ask for installation #If not installed, ask for installation
if (!($path)) { if (!($path)) {
#If -silent option, force installation #If -silent option, force installation
@ -173,7 +173,7 @@ function Install-WinGet {
If ([Version]$TestWinGet.Version -ge "2022.728.1939.0") { If ([Version]$TestWinGet.Version -ge "2022.728.1939.0") {
Write-Host "WinGet is Installed" -ForegroundColor Green Write-Host "WinGet is Installed" -ForegroundColor Green
} }
Else { Else {
@ -192,7 +192,7 @@ function Install-WinGet {
catch { catch {
Write-Host "Failed to intall Winget MSIXBundle for App Installer..." -ForegroundColor Red Write-Host "Failed to intall Winget MSIXBundle for App Installer..." -ForegroundColor Red
} }
#Remove WinGet MSIXBundle #Remove WinGet MSIXBundle
Remove-Item -Path "$PSScriptRoot\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -Force -ErrorAction Continue Remove-Item -Path "$PSScriptRoot\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -Force -ErrorAction Continue
@ -291,7 +291,7 @@ function Install-WingetAutoUpdate {
$task = New-ScheduledTask -Action $taskAction -Principal $taskUserPrincipal -Settings $taskSettings $task = New-ScheduledTask -Action $taskAction -Principal $taskUserPrincipal -Settings $taskSettings
Register-ScheduledTask -TaskName 'Winget-AutoUpdate-UserContext' -InputObject $task -Force | Out-Null Register-ScheduledTask -TaskName 'Winget-AutoUpdate-UserContext' -InputObject $task -Force | Out-Null
} }
# Settings for the scheduled task for Notifications # Settings for the scheduled task for Notifications
$taskAction = New-ScheduledTaskAction -Execute "wscript.exe" -Argument "`"$($WingetUpdatePath)\Invisible.vbs`" `"powershell.exe -NoProfile -ExecutionPolicy Bypass -File `"`"`"$($WingetUpdatePath)\winget-notify.ps1`"`"" $taskAction = New-ScheduledTaskAction -Execute "wscript.exe" -Argument "`"$($WingetUpdatePath)\Invisible.vbs`" `"powershell.exe -NoProfile -ExecutionPolicy Bypass -File `"`"`"$($WingetUpdatePath)\winget-notify.ps1`"`""
$taskUserPrincipal = New-ScheduledTaskPrincipal -GroupId S-1-5-11 $taskUserPrincipal = New-ScheduledTaskPrincipal -GroupId S-1-5-11
@ -372,7 +372,7 @@ function Install-WingetAutoUpdate {
Write-host "WAU Installation succeeded!" -ForegroundColor Green Write-host "WAU Installation succeeded!" -ForegroundColor Green
Start-sleep 1 Start-sleep 1
#Run Winget ? #Run Winget ?
Start-WingetAutoUpdate Start-WingetAutoUpdate
} }
@ -384,13 +384,13 @@ function Install-WingetAutoUpdate {
} }
function Uninstall-WingetAutoUpdate { function Uninstall-WingetAutoUpdate {
Write-Host "`nUninstalling WAU..." -ForegroundColor Yellow Write-Host "`nUninstalling WAU..." -ForegroundColor Yellow
try { try {
#Get registry install location #Get registry install location
$InstallLocation = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocation $InstallLocation = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocation
#Check if installed location exists and delete #Check if installed location exists and delete
if (Test-Path ($InstallLocation)) { if (Test-Path ($InstallLocation)) {
@ -406,7 +406,7 @@ function Uninstall-WingetAutoUpdate {
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 "HKCR\AppUserModelId\Windows.SystemToast.Winget.Notification" /f | Out-Null
& reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" /f | Out-Null & reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" /f | Out-Null
if ((Test-Path "${env:ProgramData}\Microsoft\Windows\Start Menu\Programs\Winget-AutoUpdate (WAU)")) { if ((Test-Path "${env:ProgramData}\Microsoft\Windows\Start Menu\Programs\Winget-AutoUpdate (WAU)")) {
Remove-Item -Path "${env:ProgramData}\Microsoft\Windows\Start Menu\Programs\Winget-AutoUpdate (WAU)" -Recurse -Force | Out-Null Remove-Item -Path "${env:ProgramData}\Microsoft\Windows\Start Menu\Programs\Winget-AutoUpdate (WAU)" -Recurse -Force | Out-Null
} }

View File

@ -55,7 +55,7 @@ if ($Logs) {
#Not available yet #Not available yet
$Message = $NotifLocale.local.outputs.output[5].message $Message = $NotifLocale.local.outputs.output[5].message
$MessageType = "warning" $MessageType = "warning"
Start-NotifTask $Title $Message $MessageType $Balise Start-NotifTask -Message $Message -MessageType $MessageType
} }
} }
elseif ($Help) { elseif ($Help) {
@ -67,7 +67,7 @@ else {
if (Test-WAUisRunning) { if (Test-WAUisRunning) {
$Message = $NotifLocale.local.outputs.output[8].message $Message = $NotifLocale.local.outputs.output[8].message
$MessageType = "warning" $MessageType = "warning"
Start-NotifTask $Title $Message $MessageType $Balise $OnClickAction Start-NotifTask -Message $Message -MessageType $MessageType
break break
} }
#Run scheduled task #Run scheduled task
@ -75,19 +75,19 @@ else {
#Starting check - Send notification #Starting check - Send notification
$Message = $NotifLocale.local.outputs.output[6].message $Message = $NotifLocale.local.outputs.output[6].message
$MessageType = "info" $MessageType = "info"
Start-NotifTask $Title $Message $MessageType $Balise $OnClickAction Start-NotifTask -Message $Message -MessageType $MessageType
#Sleep until the task is done #Sleep until the task is done
While (Test-WAUisRunning) { While (Test-WAUisRunning) {
Start-Sleep 3 Start-Sleep 3
} }
$Message = $NotifLocale.local.outputs.output[9].message $Message = $NotifLocale.local.outputs.output[9].message
$MessageType = "success" $MessageType = "success"
Start-NotifTask $Title $Message $MessageType $Balise $OnClickAction Start-NotifTask -Message $Message -MessageType $MessageType
} }
catch { catch {
#Check failed - Just send notification #Check failed - Just send notification
$Message = $NotifLocale.local.outputs.output[7].message $Message = $NotifLocale.local.outputs.output[7].message
$MessageType = "error" $MessageType = "error"
Start-NotifTask $Title $Message $MessageType $Balise Start-NotifTask -Message $Message -MessageType $MessageType
} }
} }

View File

@ -1,6 +1,6 @@
<# <#
.SYNOPSIS .SYNOPSIS
Uninstall Winget-AutoUpdate Uninstall Winget-AutoUpdate
.DESCRIPTION .DESCRIPTION
Uninstall Winget-AutoUpdate (DEFAULT: clean old install) Uninstall Winget-AutoUpdate (DEFAULT: clean old install)
@ -36,7 +36,7 @@ try {
Write-host "Uninstalling WAU..." -ForegroundColor Yellow Write-host "Uninstalling WAU..." -ForegroundColor Yellow
#Get registry install location #Get registry install location
$InstallLocation = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocation $InstallLocation = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocation
#Check if installed location exists and delete #Check if installed location exists and delete
if (Test-Path ($InstallLocation)) { 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" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False
Get-ScheduledTask -TaskName "Winget-AutoUpdate-Notify" -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 "HKCR\AppUserModelId\Windows.SystemToast.Winget.Notification" /f | Out-Null
& reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" /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") { 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")) { 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 Remove-Item -Path "${env:Public}\Desktop\WAU - Check for updated Apps.lnk" -Force | Out-Null
} }
Write-host "Uninstallation succeeded!" -ForegroundColor Green Write-host "Uninstallation succeeded!" -ForegroundColor Green
} }
else { else {

View File

@ -10,14 +10,14 @@ if (!($NotifConf)) {
#Load Assemblies #Load Assemblies
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null [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 [Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null
#Prepare XML #Prepare XML
$ToastXml = [Windows.Data.Xml.Dom.XmlDocument]::New() $ToastXml = [Windows.Data.Xml.Dom.XmlDocument]::New()
$ToastXml.LoadXml($NotifConf.OuterXml) $ToastXml.LoadXml($NotifConf.OuterXml)
#Specify Launcher App ID #Specify Launcher App ID
$LauncherID = "Windows.SystemToast.Winget.Notification" $LauncherID = "Windows.SystemToast.Winget.Notification"
#Prepare and Create Toast #Prepare and Create Toast
$ToastMessage = [Windows.UI.Notifications.ToastNotification]::New($ToastXML) $ToastMessage = [Windows.UI.Notifications.ToastNotification]::New($ToastXML)
$ToastMessage.Tag = $NotifConf.toast.tag $ToastMessage.Tag = $NotifConf.toast.tag

View File

@ -44,7 +44,7 @@ Write-Log "Notification Level: $($WAUConfig.WAU_NotificationLevel). Notification
if (Test-Network) { if (Test-Network) {
#Check if Winget is installed and get Winget cmd #Check if Winget is installed and get Winget cmd
$TestWinget = Get-WingetCmd $TestWinget = Get-WingetCmd
if ($TestWinget) { if ($TestWinget) {
#Get Current Version #Get Current Version
$WAUCurrentVersion = $WAUConfig.DisplayVersion $WAUCurrentVersion = $WAUConfig.DisplayVersion
@ -116,7 +116,7 @@ if (Test-Network) {
$Log | Write-host $Log | Write-host
$Log | out-file -filepath $LogFile -Append $Log | out-file -filepath $LogFile -Append
} }
#Count good update installations #Count good update installations
$Script:InstallOK = 0 $Script:InstallOK = 0
@ -161,7 +161,7 @@ if (Test-Network) {
} }
} }
} }
if ($InstallOK -gt 0) { if ($InstallOK -gt 0) {
Write-Log "$InstallOK apps updated ! No more update." "Green" Write-Log "$InstallOK apps updated ! No more update." "Green"
} }

View File

@ -17,4 +17,4 @@ function Add-ScopeMachine ($SettingsPath) {
} }
$ConfigFile | ConvertTo-Json | Out-File $SettingsPath -Encoding utf8 -Force $ConfigFile | ConvertTo-Json | Out-File $SettingsPath -Encoding utf8 -Force
} }

View File

@ -9,4 +9,4 @@ Function Get-AppInfo ($AppID) {
#Return Release Note #Return Release Note
return $ReleaseNote return $ReleaseNote
} }

View File

@ -7,5 +7,5 @@ function Get-ExcludedApps {
return (Get-Content -Path "$WorkingDir\excluded_apps.txt").Trim() | Where-Object { $_.length -gt 0 } return (Get-Content -Path "$WorkingDir\excluded_apps.txt").Trim() | Where-Object { $_.length -gt 0 }
} }
} }

View File

@ -5,7 +5,7 @@ function Get-IncludedApps {
if (Test-Path "$WorkingDir\included_apps.txt") { if (Test-Path "$WorkingDir\included_apps.txt") {
return (Get-Content -Path "$WorkingDir\included_apps.txt").Trim() | Where-Object { $_.length -gt 0 } return (Get-Content -Path "$WorkingDir\included_apps.txt").Trim() | Where-Object { $_.length -gt 0 }
} }
} }

View File

@ -1,12 +1,12 @@
#Function to get locale file for Notification. #Function to get locale file for Notification.
Function Get-NotifLocale { Function Get-NotifLocale {
#Get OS locale #Get OS locale
$OSLocale = (Get-Culture).Parent $OSLocale = (Get-Culture).Parent
#Test if OS locale notif file exists #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 #Set OS Local if file exists
if (Test-Path $TestOSLocalPath) { if (Test-Path $TestOSLocalPath) {
@ -25,4 +25,4 @@ Function Get-NotifLocale {
#Rerturn langague display name #Rerturn langague display name
Return $LocaleDisplayName Return $LocaleDisplayName
} }

View File

@ -4,21 +4,21 @@ function Get-WAUAvailableVersion {
#Get Github latest version #Get Github latest version
if ($WAUConfig.WAU_UpdatePrerelease -eq 1) { if ($WAUConfig.WAU_UpdatePrerelease -eq 1) {
#Log #Log
Write-log "WAU AutoUpdate Pre-release versions is Enabled" "Cyan" Write-log "WAU AutoUpdate Pre-release versions is Enabled" "Cyan"
#Get latest pre-release info #Get latest pre-release info
$WAUurl = 'https://api.github.com/repos/Romanitho/Winget-AutoUpdate/releases' $WAUurl = 'https://api.github.com/repos/Romanitho/Winget-AutoUpdate/releases'
} }
else { else {
#Get latest stable info #Get latest stable info
$WAUurl = 'https://api.github.com/repos/Romanitho/Winget-AutoUpdate/releases/latest' $WAUurl = 'https://api.github.com/repos/Romanitho/Winget-AutoUpdate/releases/latest'
} }
return ((Invoke-WebRequest $WAUurl -UseBasicParsing | ConvertFrom-Json)[0].tag_name).Replace("v", "") return ((Invoke-WebRequest $WAUurl -UseBasicParsing | ConvertFrom-Json)[0].tag_name).Replace("v", "")
} }

View File

@ -25,8 +25,8 @@ function Get-WingetOutdatedApps {
while (-not $lines[$fl].StartsWith("-----")) { while (-not $lines[$fl].StartsWith("-----")) {
$fl++ $fl++
} }
#Get header line #Get header line
$fl = $fl - 1 $fl = $fl - 1
#Get header titles #Get header titles
@ -59,4 +59,4 @@ function Get-WingetOutdatedApps {
} }
return $upgradeList | Sort-Object { Get-Random } return $upgradeList | Sort-Object { Get-Random }
} }

View File

@ -1,7 +1,7 @@
#Function to make actions post WAU update #Function to make actions post WAU update
function Invoke-PostUpdateActions { function Invoke-PostUpdateActions {
#log #log
Write-Log "Running Post Update actions..." "yellow" Write-Log "Running Post Update actions..." "yellow"
@ -15,7 +15,7 @@ function Invoke-PostUpdateActions {
#log #log
Write-Log "-> Winget sources reseted." "green" Write-Log "-> Winget sources reseted." "green"
} }
#Create WAU Regkey if not present #Create WAU Regkey if not present
$regPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" $regPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate"
if (!(test-path $regPath)) { if (!(test-path $regPath)) {
@ -42,7 +42,7 @@ function Invoke-PostUpdateActions {
#log #log
Write-Log "-> Notification level setting was missing. Fixed with 'Full' option." Write-Log "-> Notification level setting was missing. Fixed with 'Full' option."
} }
#Convert about.xml if exists (previous WAU versions) to reg #Convert about.xml if exists (previous WAU versions) to reg
$WAUAboutPath = "$WorkingDir\config\about.xml" $WAUAboutPath = "$WorkingDir\config\about.xml"
if (test-path $WAUAboutPath) { if (test-path $WAUAboutPath) {
@ -83,7 +83,7 @@ function Invoke-PostUpdateActions {
foreach ($FileName in $FileNames) { foreach ($FileName in $FileNames) {
if (Test-Path $FileName) { if (Test-Path $FileName) {
Remove-Item $FileName -Force -Confirm:$false Remove-Item $FileName -Force -Confirm:$false
#log #log
Write-Log "-> $FileName removed." "green" Write-Log "-> $FileName removed." "green"
} }
@ -97,5 +97,5 @@ function Invoke-PostUpdateActions {
#log #log
Write-Log "Post Update actions finished" "green" Write-Log "Post Update actions finished" "green"
} }

View File

@ -11,7 +11,7 @@ function Start-Init {
#Logs initialisation #Logs initialisation
$Script:LogFile = "$WorkingDir\logs\updates.log" $Script:LogFile = "$WorkingDir\logs\updates.log"
if (!(Test-Path $LogFile)) { if (!(Test-Path $LogFile)) {
#Create file if doesn't exist #Create file if doesn't exist
New-Item -ItemType File -Path $LogFile -Force New-Item -ItemType File -Path $LogFile -Force
@ -30,4 +30,4 @@ function Start-Init {
#Log file #Log file
$Log | out-file -filepath $LogFile -Append $Log | out-file -filepath $LogFile -Append
} }

View File

@ -143,7 +143,7 @@ function Start-NotifTask {
#Run Notify scheduled task to notify conneted users #Run Notify scheduled task to notify conneted users
Get-ScheduledTask -TaskName "Winget-AutoUpdate-Notify" -ErrorAction SilentlyContinue | Start-ScheduledTask -ErrorAction SilentlyContinue Get-ScheduledTask -TaskName "Winget-AutoUpdate-Notify" -ErrorAction SilentlyContinue | Start-ScheduledTask -ErrorAction SilentlyContinue
} }
#else, run as connected user #else, run as connected user
else { else {
@ -158,7 +158,7 @@ function Start-NotifTask {
#Specify Launcher App ID #Specify Launcher App ID
$LauncherID = "Windows.SystemToast.Winget.Notification" $LauncherID = "Windows.SystemToast.Winget.Notification"
#Prepare and Create Toast #Prepare and Create Toast
$ToastMessage = [Windows.UI.Notifications.ToastNotification]::New($ToastXml) $ToastMessage = [Windows.UI.Notifications.ToastNotification]::New($ToastXml)
$ToastMessage.Tag = $ToastTemplate.toast.tag $ToastMessage.Tag = $ToastTemplate.toast.tag
@ -171,4 +171,4 @@ function Start-NotifTask {
} }
} }

View File

@ -55,12 +55,15 @@ function Test-Network {
#Send Warning Notif if no connection for 5 min #Send Warning Notif if no connection for 5 min
if ($timeout -eq 300) { if ($timeout -eq 300) {
#Log
Write-Log "Notify 'No connection' sent." "Yellow" Write-Log "Notify 'No connection' sent." "Yellow"
#Notif
$Title = $NotifLocale.local.outputs.output[0].title $Title = $NotifLocale.local.outputs.output[0].title
$Message = $NotifLocale.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 $Title -Message $Message -MessageType $MessageType -Balise $Balise
} }
} }
@ -69,11 +72,14 @@ function Test-Network {
#Send Timeout Notif if no connection for 30 min #Send Timeout Notif if no connection for 30 min
Write-Log "Timeout. No internet connection !" "Red" Write-Log "Timeout. No internet connection !" "Red"
#Notif
$Title = $NotifLocale.local.outputs.output[1].title $Title = $NotifLocale.local.outputs.output[1].title
$Message = $NotifLocale.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 $Title -Message $Message -MessageType $MessageType -Balise $Balise
return $false return $false
} }

View File

@ -1,23 +1,23 @@
#Function to check if there's a Pending Reboot #Function to check if there's a Pending Reboot
function Test-PendingReboot { function Test-PendingReboot {
$Computer = $env:COMPUTERNAME $Computer = $env:COMPUTERNAME
$PendingReboot = $false $PendingReboot = $false
$HKLM = [UInt32] "0x80000002" $HKLM = [UInt32] "0x80000002"
$WMI_Reg = [WMIClass] "\\$Computer\root\default:StdRegProv" $WMI_Reg = [WMIClass] "\\$Computer\root\default:StdRegProv"
if ($WMI_Reg) { 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\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 } if (($WMI_Reg.EnumKey($HKLM, "SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\")).sNames -contains 'RebootRequired') { $PendingReboot = $true }
#Checking for SCCM namespace #Checking for SCCM namespace
$SCCM_Namespace = Get-WmiObject -Namespace ROOT\CCM\ClientSDK -List -ComputerName $Computer -ErrorAction Ignore $SCCM_Namespace = Get-WmiObject -Namespace ROOT\CCM\ClientSDK -List -ComputerName $Computer -ErrorAction Ignore
if ($SCCM_Namespace) { if ($SCCM_Namespace) {
if (([WmiClass]"\\$Computer\ROOT\CCM\ClientSDK:CCM_ClientUtilities").DetermineIfRebootPending().RebootPending -eq $true) { $PendingReboot = $true } if (([WmiClass]"\\$Computer\ROOT\CCM\ClientSDK:CCM_ClientUtilities").DetermineIfRebootPending().RebootPending -eq $true) { $PendingReboot = $true }
} }
} }
return $PendingReboot return $PendingReboot

View File

@ -3,7 +3,10 @@
Function Update-App ($app) { Function Update-App ($app) {
#Get App Info #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 #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"
@ -11,11 +14,11 @@ Function Update-App ($app) {
$Message = $NotifLocale.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 $OnClickAction Start-NotifTask -Title $Title -Message $Message -MessageType $MessageType -Balise $Balise -Button1Action $ReleaseNoteURL -Button1Text $Button1Text
#Winget upgrade #Winget upgrade
Write-Log "########## WINGET UPGRADE PROCESS STARTS FOR APPLICATION ID '$($App.Id)' ##########" "Gray" Write-Log "########## WINGET UPGRADE PROCESS STARTS FOR APPLICATION ID '$($App.Id)' ##########" "Gray"
#Run Winget Upgrade command #Run Winget Upgrade command
Write-Log "-> Running: Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements -h" 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 & $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 $FailedToUpgrade = $false
foreach ($CheckApp in $CheckOutdated) { foreach ($CheckApp in $CheckOutdated) {
if ($($CheckApp.Id) -eq $($app.Id)) { if ($($CheckApp.Id) -eq $($app.Id)) {
#Upgrade failed! #Upgrade failed!
#Test for a Pending Reboot (Component Based Servicing/WindowsUpdate/CCM_ClientUtilities) #Test for a Pending Reboot (Component Based Servicing/WindowsUpdate/CCM_ClientUtilities)
$PendingReboot = Test-PendingReboot $PendingReboot = Test-PendingReboot
@ -37,7 +40,7 @@ Function Update-App ($app) {
$FailedToUpgrade = $true $FailedToUpgrade = $true
break break
} }
#If app failed to upgrade, run Install command #If app failed to upgrade, run Install command
Write-Log "-> An upgrade for $($app.Name) failed, now trying an install instead..." "Yellow" 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" 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 #Notify installation
if ($FailedToUpgrade -eq $false) { if ($FailedToUpgrade -eq $false) {
#Send success updated app notification #Send success updated app notification
Write-Log "$($app.Name) updated to $($app.AvailableVersion) !" "Green" Write-Log "$($app.Name) updated to $($app.AvailableVersion) !" "Green"
#Send Notif #Send Notif
$Title = $NotifLocale.local.outputs.output[3].title -f $($app.Name) $Title = $NotifLocale.local.outputs.output[3].title -f $($app.Name)
$Message = $NotifLocale.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 $OnClickAction Start-NotifTask -Title $Title -Message $Message -MessageType $MessageType -Balise $Balise -Button1Action $ReleaseNoteURL -Button1Text $Button1Text
$Script:InstallOK += 1 $Script:InstallOK += 1
} }
else { else {
#Send failed updated app notification #Send failed updated app notification
Write-Log "$($app.Name) update failed." "Red" Write-Log "$($app.Name) update failed." "Red"
#Send Notif #Send Notif
$Title = $NotifLocale.local.outputs.output[4].title -f $($app.Name) $Title = $NotifLocale.local.outputs.output[4].title -f $($app.Name)
$Message = $NotifLocale.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 $OnClickAction Start-NotifTask -Title $Title -Message $Message -MessageType $MessageType -Balise $Balise -Button1Action $ReleaseNoteURL -Button1Text $Button1Text
} }
} }

View File

@ -3,22 +3,22 @@
function Update-WAU { function Update-WAU {
$OnClickAction = "https://github.com/Romanitho/Winget-AutoUpdate/releases" $OnClickAction = "https://github.com/Romanitho/Winget-AutoUpdate/releases"
$Button1Text = $NotifLocale.local.outputs.output[10].message
#Send available update notification #Send available update notification
$Title = $NotifLocale.local.outputs.output[2].title -f "Winget-AutoUpdate" $Title = $NotifLocale.local.outputs.output[2].title -f "Winget-AutoUpdate"
$Message = $NotifLocale.local.outputs.output[2].message -f $WAUCurrentVersion, $WAUAvailableVersion $Message = $NotifLocale.local.outputs.output[2].message -f $WAUCurrentVersion, $WAUAvailableVersion
$MessageType = "info" $MessageType = "info"
$Balise = "Winget-AutoUpdate" Start-NotifTask -Title $Title -Message $Message -MessageType $MessageType -Button1Action $OnClickAction -Button1Text $Button1Text
Start-NotifTask $Title $Message $MessageType $Balise $OnClickAction
#Run WAU update #Run WAU update
try { try {
#Force to create a zip file #Force to create a zip file
$ZipFile = "$WorkingDir\WAU_update.zip" $ZipFile = "$WorkingDir\WAU_update.zip"
New-Item $ZipFile -ItemType File -Force | Out-Null New-Item $ZipFile -ItemType File -Force | Out-Null
#Download the zip #Download the zip
Write-Log "Downloading the GitHub Repository version $WAUAvailableVersion" "Cyan" 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 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" $location = "$WorkingDir\WAU_update"
Expand-Archive -Path $ZipFile -DestinationPath $location -Force Expand-Archive -Path $ZipFile -DestinationPath $location -Force
Get-ChildItem -Path $location -Recurse | Unblock-File Get-ChildItem -Path $location -Recurse | Unblock-File
#Update scritps #Update scritps
Write-Log "Updating WAU" "Yellow" Write-Log "Updating WAU" "Yellow"
$TempPath = (Resolve-Path "$location\*\Winget-AutoUpdate\")[0].Path $TempPath = (Resolve-Path "$location\*\Winget-AutoUpdate\")[0].Path
if ($TempPath) { if ($TempPath) {
Copy-Item -Path "$TempPath\*" -Destination "$WorkingDir\" -Exclude "icons" -Recurse -Force Copy-Item -Path "$TempPath\*" -Destination "$WorkingDir\" -Exclude "icons" -Recurse -Force
} }
#Remove update zip file and update temp folder #Remove update zip file and update temp folder
Write-Log "Done. Cleaning temp files" "Cyan" Write-Log "Done. Cleaning temp files" "Cyan"
Remove-Item -Path $ZipFile -Force -ErrorAction SilentlyContinue Remove-Item -Path $ZipFile -Force -ErrorAction SilentlyContinue
@ -53,8 +53,7 @@ function Update-WAU {
$Title = $NotifLocale.local.outputs.output[3].title -f "Winget-AutoUpdate" $Title = $NotifLocale.local.outputs.output[3].title -f "Winget-AutoUpdate"
$Message = $NotifLocale.local.outputs.output[3].message -f $WAUAvailableVersion $Message = $NotifLocale.local.outputs.output[3].message -f $WAUAvailableVersion
$MessageType = "success" $MessageType = "success"
$Balise = "Winget-AutoUpdate" Start-NotifTask -Title $Title -Message $Message -MessageType $MessageType -Button1Action $OnClickAction -Button1Text $Button1Text
Start-NotifTask $Title $Message $MessageType $Balise $OnClickAction
#Rerun with newer version #Rerun with newer version
Write-Log "Re-run WAU" Write-Log "Re-run WAU"
@ -65,15 +64,14 @@ function Update-WAU {
} }
catch { catch {
#Send Error Notif #Send Error Notif
$Title = $NotifLocale.local.outputs.output[4].title -f "Winget-AutoUpdate" $Title = $NotifLocale.local.outputs.output[4].title -f "Winget-AutoUpdate"
$Message = $NotifLocale.local.outputs.output[4].message $Message = $NotifLocale.local.outputs.output[4].message
$MessageType = "error" $MessageType = "error"
$Balise = "Winget-AutoUpdate" Start-NotifTask -Title $Title -Message $Message -MessageType $MessageType -Button1Action $OnClickAction -Button1Text $Button1Text
Start-NotifTask $Title $Message $MessageType $Balise $OnClickAction
Write-Log "WAU Update failed" "Red" Write-Log "WAU Update failed" "Red"
} }
} }

View File

@ -1,7 +1,7 @@
#Write Log Function #Write Log Function
function Write-Log ($LogMsg, $LogColor = "White") { function Write-Log ($LogMsg, $LogColor = "White") {
#Get log #Get log
$Log = "$(Get-Date -UFormat "%T") - $LogMsg" $Log = "$(Get-Date -UFormat "%T") - $LogMsg"
@ -11,4 +11,4 @@ function Write-Log ($LogMsg, $LogColor = "White") {
#Write log to file #Write log to file
$Log | Out-File -FilePath $LogFile -Append $Log | Out-File -FilePath $LogFile -Append
} }

View File

@ -49,6 +49,10 @@
<output id="9"> <output id="9">
<!--Manual check for updated apps completed--> <!--Manual check for updated apps completed-->
<message>Die manuelle suche nach Updates wurde abgeschlossen.</message> <message>Die manuelle suche nach Updates wurde abgeschlossen.</message>
<output id="10">
<!--See changelog-->
<message>See changelog</message>
</output>
</output> </output>
</outputs> </outputs>
</local> </local>

View File

@ -50,5 +50,9 @@
<!--Manual check for updated apps completed--> <!--Manual check for updated apps completed-->
<message>Manual check for updated apps completed...</message> <message>Manual check for updated apps completed...</message>
</output> </output>
<output id="10">
<!--See changelog-->
<message>See changelog</message>
</output>
</outputs> </outputs>
</local> </local>

View File

@ -50,5 +50,9 @@
<!--Manual check for updated apps completed--> <!--Manual check for updated apps completed-->
<message>Manual check for updated apps completed...</message> <message>Manual check for updated apps completed...</message>
</output> </output>
<output id="10">
<!--See changelog-->
<message>See changelog</message>
</output>
</outputs> </outputs>
</local> </local>

View File

@ -50,5 +50,9 @@
<!--Manual check for updated apps completed--> <!--Manual check for updated apps completed-->
<message>Manual check for updated apps completed...</message> <message>Manual check for updated apps completed...</message>
</output> </output>
<output id="10">
<!--See changelog-->
<message>See changelog</message>
</output>
</outputs> </outputs>
</local> </local>

View File

@ -50,5 +50,9 @@
<!--Manual check for updated apps completed--> <!--Manual check for updated apps completed-->
<message>Recherche de mises à jour terminée.</message> <message>Recherche de mises à jour terminée.</message>
</output> </output>
<output id="10">
<!--See changelog-->
<message>Consulter le journal des modifications</message>
</output>
</outputs> </outputs>
</local> </local>

View File

@ -50,5 +50,9 @@
<!--Manual check for updated apps completed--> <!--Manual check for updated apps completed-->
<message>A frissített alkalmazások kézi ellenőrzése befejeződött...</message> <message>A frissített alkalmazások kézi ellenőrzése befejeződött...</message>
</output> </output>
<output id="10">
<!--See changelog-->
<message>See changelog</message>
</output>
</outputs> </outputs>
</local> </local>

View File

@ -50,5 +50,9 @@
<!--Manual check for updated apps completed--> <!--Manual check for updated apps completed-->
<message>Manual check for updated apps completed...</message> <message>Manual check for updated apps completed...</message>
</output> </output>
<output id="10">
<!--See changelog-->
<message>See changelog</message>
</output>
</outputs> </outputs>
</local> </local>

View File

@ -50,5 +50,9 @@
<!--Manual check for updated apps completed--> <!--Manual check for updated apps completed-->
<message>Manual check for updated apps completed...</message> <message>Manual check for updated apps completed...</message>
</output> </output>
<output id="10">
<!--See changelog-->
<message>See changelog</message>
</output>
</outputs> </outputs>
</local> </local>

View File

@ -50,5 +50,9 @@
<!--Manual check for updated apps completed--> <!--Manual check for updated apps completed-->
<message>Manual check for updated apps completed...</message> <message>Manual check for updated apps completed...</message>
</output> </output>
<output id="10">
<!--See changelog-->
<message>See changelog</message>
</output>
</outputs> </outputs>
</local> </local>

View File

@ -50,5 +50,9 @@
<!--Manual check for updated apps completed--> <!--Manual check for updated apps completed-->
<message>Manuell koll efter uppdaterade appar slutförd...</message> <message>Manuell koll efter uppdaterade appar slutförd...</message>
</output> </output>
<output id="10">
<!--See changelog-->
<message>See changelog</message>
</output>
</outputs> </outputs>
</local> </local>