Nazaudy, a spark in your curious mind

Useful powershell scripts

These Useful powershell scripts can help you manage your environment:

 

Robocopy to copy content from A to B

 

 

User account locks

Import-Module activedirectory
$users = Search-ADAccount -LockedOut | Select-Object -ExpandProperty SamAccountName 
ForEach ($user in $users)
{
$test = Get-AdUser $user -Properties * 
$Body = $test.CN + " " + "account was locked out. It is now unlocked"
Send-MailMessage -To $test.Manager -Subject "Below Users LAN ID is locked" -SmtpServer "smtp.gmail.com" -From "This email address is being protected from spambots. You need JavaScript enabled to view it."  -Body $Body
}
Search-ADAccount -LockedOut | Unlock-ADAccount