5 The power unlock

 

This chapter covers:

  • Storing large amounts of objects and referencing them individually or in groups.
  • Performing actions to any number of objects transforming dozens or thousands of tasks to a single click.
  • Unlocking Specific locked user accounts without having to search Active Directory.
  • Unlocking your whole domain with three lines of code.

If there’s one constant in the world of IT it’s the fact that users will lock themselves out and come to you, the admin, to unlock them.  Typically, this involves opening up Active Directory Users and Computers and then searching for the user, opening their account clicking on a tab and checking a box.

It doesn’t take up a ton of time.  But it is something that can be made much easier with PowerShell.  Now, imagine, for a moment that you have a network issue in one of your remote locations.  Some service has stopped and all of your users in a particular geographic area are locked out. 

At this point you can be reactive and wait for tickets or phone calls to roll in and unlock the users one by one.  Or with the use of this script, you can see with a single click that there is a significant number of users from any given network location that are locked out.

This simple inclusion in a script that you’d be using to make your life easier can take you from reactive to IT superstar.

5.1 What Does the Script do?

5.2 Project Code

5.3 Arrays: a great place to keep your stuff

5.4 Loops

5.5 PSObjects

5.6 Unlock-ADAccount

5.7 Try this too

5.7.1 Unlock All Locked Accounts.

5.8 Summary