Using powershell Search-ADAccount Command for Users&Computers

List Enabled Users

Get-ADUser -Filter ‘enabled -eq $true’ |fl name

 List disabled users

Search-ADAccount -AccountDisabled -UsersOnly

Get-ADUser -Filter {Enabled -eq $false} | FT samAccountName, GivenName, Surname

Returns all users, computers and service accounts that are expired.

Search-ADAccount -AccountExpired | FT Name,ObjectClass -A

Returns all users, computers and service accounts that will expire in the next 6 days.

Search-ADAccount -AccountExpiring -TimeSpan 6.00:00:00 | FT Name,ObjectClass -A

Returns all accounts that have been inactive for the last 90 days.

Search-ADAccount -AccountInactive -TimeSpan 90.00:00:00 | FT Name,ObjectClass -A

 

Returns all accounts where the password has expired.

Search-ADAccount -PasswordExpired | FT Name,ObjectClass -A

 

Returns all accounts with a password that will never expire.

Search-ADAccount -PasswordNeverExpires | FT Name,ObjectClass -A

 

Returns all accounts that have been locked out.

Search-ADAccount -LockedOut | FT Name,ObjectClass -A

 

Returns all disabled computer accounts.

Search-ADAccount -AccountDisabled -ComputersOnly | FT Name,ObjectClass -A

Returns all accounts which expire on the 18th of March, 2009.

Search-ADAccount -AccountExpiring -DateTime “3/18/2009” | FT Name,ObjectClass -A

Related Link