Saturday, March 24, 2012

Powershell Script: Currently locked out accounts

The Microsoft certification training I'm doing now is just scratching the surface of what is possible with powershell but it was so intriguing I couldn't not do more research into what's possible with it. Even for those of us that don't have the time to essentially learn a whole new programming language can get quick benefits from learning a small amount.

Locked out active directory accounts are a constant problem (that I will discuss in a later post) where I work. But from a users  perspective they could be having a problem with "getting to the internet", "wifi", "email", or even "printing". All these services we provide hinge on their active directory account being in good working order.

So instead of manually searching for a users account these days I just use a powershell script to check if ANY accounts on the domain are locked out. At this point I just keep a powershell window open and hit Up Arrow and Enter to execute the script again.

Open up notepad or your text editor of choice and type the following:

Search-ADAccount -LockedOut | FT Name, ObjectClass, UserPrincipalName

Save this text file as lockedout.ps1

Now just open powershell and run your script!

No comments:

Post a Comment