Notification for deployed auto updates
Hi everyone,
last week I was wondering if it is poosible to activate an e-mail notification whenever a new version gets auto-approved and deployed in our network. We just need notifications for software that is actually in out auto-approval. Since Jason told me there is no function like that in PDQ Deploy (yet ;) ) I wrote a little PowerShellScript that I wanted to share with you:
We set up a reference-client on which we scheduled a daily PowerShell-Task to check the installdate of installed applications. If the date equals the actual date, the machine generates an e-mail and creates a ticket for the administrators.
If there is no installation, the script just writes a line to a logfile.
What needs to be customized is the Mailadress and SMTP-Relayserver.
Here weg go:
$checkdate = (get-date).year,(get-date).month,(get-date).day -join ""
$displaydate = (get-date).ToShortDateString()
$trigger = New-JobTrigger -daily -at "23:59PM"
$x86 = Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | select DisplayName, Installdate | sort Installdate
$x64 = Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | select DisplayName, Installdate | sort Installdate
$x86 = $x86 | where installdate -eq $checkdate
$x64 = $x64 | where installdate -eq $checkdate
$x86name = $x86.displayname
$x64name = $x64.displayname
$x86display = foreach ($line in $x86name){"$line`n"}
$x64display = foreach ($line in $x64name){"$line`n"}
$action = {If($x86 -or $x64){
$body ="Reference-PC VLAPH724: Updates Applications $displaydate`n`n$x86display`n$x64display"
$body | Out-File c:\logs\SoftwareUpdate.txt -Append
Send-MailMessage -From your@mailadress.com -Subject "Applications updated" -To supportdesk@mailadress.com -Body "$body" -SmtpServer relay.mailadress.com
}
Else{
"No Updates on $displaydate" | Out-File c:\logs\SoftwareUpdate.txt -Append
}
}
Register-ScheduledJob -name "Update Check" -ScriptBlock $action -trigger $trigger
Feel free to share or comment!
Regards
Ralf
Comments
Straightforward, with an intentional purpose. No fluff or fancy tricks. I like it. Thanks for sharing.