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 = “192.168.1.2”
$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′”

http://www.quest.com/powershell/activeroles-server.aspx

Advertisements

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.

________________________________________________________

<?php
mysql_connect(“localhost”, “root”, “password”) or
die(“Could not connect: ” . mysql_error());
mysql_select_db(“cacti”);

$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);

}

mysql_free_result($result);

?>

________________________________________________________________

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!