Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Thursday, April 28, 2016 9:38 AM
Hello,
I am trying to populate the contact table of an application. I want import all enabled Active Directory user accounts, but not those that have expired.
Does anyone know how can I achieve this using the Get-ADUser cmdlet ?
Get-ADUser -Filter 'enabled -eq $true'
Thanks
Stuart

All replies (1)
Thursday, April 28, 2016 10:07 AM | 1 vote
you can use Search-ADAccount -AccountExpired
to get a list of all expired accounts and then filter these accounts from output of your Get-ADUser command.
https://technet.microsoft.com/en-us/library/ee617247.aspx
Note that apart from user accounts, Search-ADAccount returns other object types as well. so you will need to use appropriate filters.
cheers..uc