PS C:\> 'server1','server2','Badserver' | Set-UserPassword -Username 'test' -Password 'pass123' -Verbose VERBOSE: Processing server 'server1'... VERBOSE: Connected to server 'server1'... VERBOSE: Retrieved user objects from server 'server1'... VERBOSE: Found user 'test' from server 'server1'... 10/12/2015 14:41:31 - Successfully changed password for user 'test' on server 'server1' VERBOSE: Processing server 'server2'... VERBOSE: Connected to server 'server2'... VERBOSE: Retrieved user objects from server 'server2'... WARNING: ERROR: No user 'test' on server 'server2' VERBOSE: Processing server 'Badserver'... WARNING: ERROR: Failed to connect to server 'Badserver' PS C:\>
About Me
My Links
Monday, October 12, 2015
Powershell Script - Set-UserPassword - Remotely sets local account passwords
Here's a great script to change passwords in bulk on many servers. I've added verbose and error output for logging purposes as well as time/date stamping for when actual password setting occurs.
Monday, October 5, 2015
Powershell Quick Script - Get emailed when a specific account is locked
Here's something quick and simple which sends you an email when an AD user account is locked out. The script just runs in a loop, polling ever 30 seconds and then finishes once the account is locked out. This requires a SMTP relay or receive connector on your exchange server to receive email.
$username = 'myuser' While(Get-AdUser $username).enabled){Start-Sleep -Seconds 30} Send-MailMessage -To 'admin@domain.com' -From 'YourPSscript@domain.com' -Subject "Account locked out - $username" ` -SmtpServer exchangeserver -Body "Your account $username"
Subscribe to:
Posts (Atom)