Write-ToLog

pull/339/head^2
Romain 2023-04-23 17:00:25 +02:00 committed by GitHub
parent 7aea648d46
commit a16313b367
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 6 deletions

View File

@ -21,7 +21,7 @@ https://github.com/Romanitho/Winget-AutoUpdate
param( param(
[Parameter(Mandatory = $False)] [Switch] $Logs = $false, [Parameter(Mandatory = $False)] [Switch] $Logs = $false,
[Parameter(Mandatory = $False)] [Switch] $Help = $false, [Parameter(Mandatory = $False)] [Switch] $Help = $false,
[Parameter(Mandatory = $False)] [String] $NotifApproved, [Parameter(Mandatory = $False)] [String] $NotifApproved
) )
function Test-WAUisRunning { function Test-WAUisRunning {
@ -103,8 +103,11 @@ else {
$MessageType = "success" $MessageType = "success"
$Message = $NotifLocale.local.outputs.output[9].message $Message = $NotifLocale.local.outputs.output[9].message
} }
$IsUserApprovalEnable = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name WAU_UserApproval -ErrorAction SilentlyContinue).WAU_UserApproval
if ($IsUserApprovalEnable -ne "1"){
Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss -UserRun Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss -UserRun
} }
}
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

View File

@ -238,23 +238,23 @@ if (Test-Network) {
#Ask user to approve, if configured #Ask user to approve, if configured
if ($WAUConfig.WAU_UserApproval -eq 1){ if ($WAUConfig.WAU_UserApproval -eq 1){
Write-Log "User Approval feature enabled." Write-ToLog "User Approval feature enabled."
#Check for approved tag #Check for approved tag
$WAUNotifApproved = "$WorkingDir/Config/NotifApproved.txt" $WAUNotifApproved = "$WorkingDir/Config/NotifApproved.txt"
if (Test-Path $WAUNotifApproved) { if (Test-Path $WAUNotifApproved) {
Write-Log "-> User approved notification." Write-ToLog "-> User approved notification."
Remove-Item $WAUNotifApproved -Force -Confirm:$false Remove-Item $WAUNotifApproved -Force -Confirm:$false
} }
else { else {
$UserApprovalReturn = Invoke-UserApproval $outdated $UserApprovalReturn = Invoke-UserApproval $outdated
if ($UserApprovalReturn -eq 0){ if ($UserApprovalReturn -eq 0){
Write-Log "-> User approval requested. Waiting for user to approve available updates... Closing for now." Write-ToLog "-> User approval requested. Waiting for user to approve available updates... Closing for now."
#Closing job, waiting for user approval #Closing job, waiting for user approval
Exit 0 Exit 0
} }
else{ else{
Write-log "-> No update to request to user." Write-ToLog "-> No update to request to user."
} }
} }
} }