FYI..!
The first thing to do is to import the ActiveDirectory module by using the Import-Module cmdlet. This command is shown here:
Import-Module activedirectory
Example: Once the module is imported, use the Search-ADAccount cmdlet with the lockedout parameter. This command is shown here:
Search-ADAccount –LockedOut
PS C:\Users\TimBolton> Get-Help Search-ADAccount
NAME
Search-ADAccount
SYNOPSIS
Gets Active Directory user, computer, or service accounts.
SYNTAX
Search-ADAccount -AccountDisabled <switch> [-AuthType {Negotiate | Basic}] [-ComputersOnly <switch>] [-Credential <
PSCredential>] [-ResultPageSize <int>] [-ResultSetSize <System.Nullable[int]>] [-SearchBase <string>] [-SearchScope
{Base | OneLevel | Subtree}] [-Server <string>] [-UsersOnly <switch>] [<CommonParameters>]
Search-ADAccount -AccountExpired <switch> [-AuthType {Negotiate | Basic}] [-ComputersOnly <switch>] [-Credential <P
SCredential>] [-ResultPageSize <int>] [-ResultSetSize <System.Nullable[int]>] [-SearchBase <string>] [-SearchScope
{Base | OneLevel | Subtree}] [-Server <string>] [-UsersOnly <switch>] [<CommonParameters>]
Search-ADAccount -AccountExpiring <switch> [-DateTime <DateTime>] [-TimeSpan <TimeSpan>] [-AuthType {Negotiate | Ba
sic}] [-ComputersOnly <switch>] [-Credential <PSCredential>] [-ResultPageSize <int>] [-ResultSetSize <System.Nullab
le[int]>] [-SearchBase <string>] [-SearchScope {Base | OneLevel | Subtree}] [-Server <string>] [-UsersOnly <switch>
] [<CommonParameters>]
Search-ADAccount -AccountInactive <switch> [-DateTime <DateTime>] [-TimeSpan <TimeSpan>] [-AuthType {Negotiate | Ba
sic}] [-ComputersOnly <switch>] [-Credential <PSCredential>] [-ResultPageSize <int>] [-ResultSetSize <System.Nullab
le[int]>] [-SearchBase <string>] [-SearchScope {Base | OneLevel | Subtree}] [-Server <string>] [-UsersOnly <switch>
] [<CommonParameters>]
Search-ADAccount -LockedOut [-AuthType {Negotiate | Basic}] [-ComputersOnly <switch>] [-Credential <PSCredential>]
[-ResultPageSize <int>] [-ResultSetSize <System.Nullable[int]>] [-SearchBase <string>] [-SearchScope {Base | OneLev
el | Subtree}] [-Server <string>] [-UsersOnly <switch>] [<CommonParameters>]
Search-ADAccount -PasswordExpired <switch> [-AuthType {Negotiate | Basic}] [-ComputersOnly <switch>] [-Credential <
PSCredential>] [-ResultPageSize <int>] [-ResultSetSize <System.Nullable[int]>] [-SearchBase <string>] [-SearchScope
{Base | OneLevel | Subtree}] [-Server <string>] [-UsersOnly <switch>] [<CommonParameters>]
Search-ADAccount -PasswordNeverExpires <switch> [-AuthType {Negotiate | Basic}] [-ComputersOnly <switch>] [-Credent
ial <PSCredential>] [-ResultPageSize <int>] [-ResultSetSize <System.Nullable[int]>] [-SearchBase <string>] [-Search
Scope {Base | OneLevel | Subtree}] [-Server <string>] [-UsersOnly <switch>] [<CommonParameters>]
DESCRIPTION
The Search-ADAccount cmdlet retrieves one or more user, computer, or service accounts that meet the criteria specif
ied by the parameters. Search criteria include account and password status. For example, you can search for all acc
ounts that have expired by specifying the AccountExpired parameter. Similarly, you can search for all accounts with
an expired password by specifying the PasswordExpired parameter. You can limit the search to user accounts by spec
ifying the UsersOnly parameter. Similarly, when you specify the ComputersOnly parameter, the cmdlet only retrieves
computer accounts.
Some search parameters, such as AccountExpiring and AccountInactive use a default time that you can change by speci
fying the DateTime or TimeSpan parameter. The DateTime parameter specifies a distinct time. The TimeSpan parameter
specifies a time range from the current time. For example, to search for all accounts that expire in 10 days, speci
fy the AccountExpiring and TimeSpan parameter and set the value of TimeSpan to "10.00:00:00". To search for all acc
ounts that expire before December 31, 2012, set the DateTime parameter to "12/31/2012".
RELATED LINKS
Online version: http://go.microsoft.com/fwlink/?LinkID=144989
Enable-ADAccount
Disable-ADAccount
Unlock-ADAccount
Set-ADAccountControl
Set-ADAccountExpiration
Clear-ADAccountExpiration
Set-ADAccountPassword
Get-ADAccountResultantPasswordReplicationPolicy
REMARKS
To see the examples, type: "get-help Search-ADAccount -examples".
For more information, type: "get-help Search-ADAccount -detailed".
For technical information, type: "get-help Search-ADAccount -full".