Notify on locked accounts

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
$SleepTime = 60 #seconds
do {
    if (Search-ADAccount -LockedOut) {
        foreach ($user in (Search-ADAccount -LockedOut)) {
            New-Burnttoastnotification -text "Locked-Out User Notification", "$($($user).name) is now Locked-Out"
        }
    }
    start-sleep -Seconds $SleepTime
}
while ($True)