unlock locked user account powershell alert mail active directory schedule task

Very simple PowerShell script to unlock Active Directory users accounts which are locked.

Get-QADUser -Locked | Unlock-QADUser


PS1: (locked_account.ps1)

$output = Get-QADUser -Locked
If ($output -ne $Null) {
$emailFrom = “alert@mail.cz
$emailTo = “admin@mail.cz
$subject = “locked accounts”
$body = $output
$smtpServer = “”
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($emailFrom, $emailTo, $subject, $body)

CMD: (Schedule task)

PowerShell.exe -PSConsoleFile “C:\Program Files\Quest Software\Management Shell for AD\ConsoleSettings.psc1” “& ‘c:\locked_account.ps1′”


cacti on windows | send alert e-mail

Cacti monitoring on windows

Are you looking for plugin which extend cacti for e-mail alerting when host is inaccessible? No problem.

You can solve it with script to db!

Save this script as the alert.php and run as a schedule task like the poller.php.


mysql_connect(“localhost”, “root”, “password”) or
die(“Could not connect: ” . mysql_error());

$result = mysql_query(“select description from host where status<>3 and disabled<>’on'”);

while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$message=”Device “. $row[‘description’] .” is INACCESSIBLE | more on http://localhost/cacti“;
mail(“your-mail@domain.com“, “Cacti ALERT”, $message);





Example how to run poller.php (the same settings  for alert.php):

poller.bat (alert.bat.) run as a schedule task:

cd c:\php\
start /min php “c:\inetpub\wwwroot\cacti\poller.php”

– – – – – – – – – –

Special thanks to my colleague Roman and Cacti developers!