Finding disabled users

by Villdyret at 2012-09-03 13:40:14

Hi. I would like a nice little command that can give me all the users in a spesific OU, with Fullname and Alias.
I would also like to find all the disabled users, and expired users within the same OU. Can anyone help?
by mjolinor at 2012-09-03 14:19:02
Using the AD module comdlets:
For the first:

get-ADUser <user> -SearchRoot <OU to search> -properties mailNickname |
select @{l='Fullname';e={$.Name}},@{l='Alias';e={$.mailNickname}}


For the second:

Search-ADAccount -SearchBase <OU to search> -AccountDisabled
Search-ADAccount -SearchBase <OU to search> -AccountExpired