This can be considered the least interesting usage of PowerShell and in many ways, not only a source of unwanted interruption, but there are situation where been able to show a toaster or pop-up can be handy.
I was inspired to write this script and article by this scripting guys’ blog post
https://blogs.technet.microsoft.com/heyscriptingguy/2014/04/04/powertip-use-powershell-to-display-pop-up-window/
The script shows a pop-up notification for 15 seconds with a list of Active Directory Users that are locked out, and this script can be schedule to run it every 5 minutes.
#
# Paolo Frigo, www.scriptinglibrary.com
#
header="".ToUpper()
$footer=" This message will close automatically in $TimeOut seconds.".ToUpper()
$NameList = ""
$TimeOut = 15 #seconds
$LockedOutUsersList = Search-ADAccount -LockedOut | Where-Object {$_.enabled -eq $true}
if ($LockedOutUsersList.Length -gt 0){
foreach ($AdUser in $LockedOutUsersList){
$NameList += "$AdUser, "
}
$wshell = New-Object -ComObject Wscript.Shell
$wshell.Popup($header+$NameList+$footer,$TimeOut,"AD USERS LOCKED OUT",0)
}
exit 0
By the way, this is not a replacement for proper group policy management of domain account lockout policy, in fact it’s more like an Ops notification with no real-time reaction or trigger by any specific event.


