Thursday, December 8, 2011

Script for some basic Login and Exchange info

This needs the Quest Active roles Snapin...

Download it Quest Downloads Page follow the instructions.

from a Powershell session type

add-PSSnapin quest.activeroles.admanagement


Script contents
$user = read-host "Enter Username in the following format....LastName.GivenName"
get-qaduser Domain-Name\$user | fl -property displayname,email,phonenumber,userprincipalname,lastlogontimestamp,lastlogon,lastlogoff,dn,homedirectory,passwordstatus,accountislockedout,accountisdisabled,memberof,nestedmemberof,passwordstatus,tsprofilepath
get-qaduser “$user” -IncludedProperties homeMDB | fl Name,homeMDB


The GET-QADUSER can bring back a whole stack of info, if you try typing it at the powershell prompt with your own account, somthing like this....

get-qaduser domain-name\user-name

Then a whole load of info will fly up the screen, you dont need it all so I've used the PIPE redirector to use the FORMAT-LIST command and with the -PROPERTY switch listed specific properties for an AD account. The mailbox info can be retrieved using the second line which specifically targets Exchange which by default is not listed, so you need to tell the command to include the exchange properties, again I've PIPED that through the FORMAT-LIST command and targeted the name and home Mailbox database info.

The $user is a variable that holds the user name you enter when the script runs, you can add or remove any property you want, I've just used ones that I feel are improtant for doing simple AD account admin for now, and it's always handy to know what Exchnage server someone is on incase that is off for maintenance or has a fault.

No comments:

Post a Comment