Powershell AD Commands

If you have the RSAT installed on Windows 7 or 8 you also get the powershell active directory module.

To install the module issue the command

import-module activedirectory

If you want to load it every time add the command to your profile

You profile is located at '\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1'

You might have to create the WindowsPowerShell directory. You can always find your profile by typing $profile at the powershell prompt

 

After you have the module loaded here are a few nice commands

Note where ever you have <> this signifies some data you would enter without the <>

 

To get all the people locked out if AD

Search-ADAccount -locked

To unlock someone

unlock-adaccount <user #>

To get information about a user

get-aduser <user #>

or one I like the old net command better

net user <user #> /domain

To change a users password

set-adaccountpassword <user #> -newpassword <password> -reset

Information about a computer

get-adcomputer <name>

There are lots more -- to see the possibilities type

get-command *-ad*

and to find out the syntax for a command and other help

help <command name>

To get all members of an OU

Get-ADUser -Filter * -SearchBase "ou=non employee,ou=users,dc=somewhere,dc=org" | select samaccountname,name,enabled | export-csv -notypeinformation nonemployee.csv