JAMES125
asked on
Powershell for inactive active directory accounts
I can use the following script to list inactive accouts but how do I narrow the search down to a specific container?
Search-ADAccount -AccountInactive -TimeSpan 30.00:00:00 | Where{$_.enabled -eq $true} | %{Get-ADUser $_.ObjectGuid} | select name, givenname, surname | export-csv c:\users\username\desktop\ unusedacco unts.csv -NoTypeInformation
-James
Search-ADAccount -AccountInactive -TimeSpan 30.00:00:00 | Where{$_.enabled -eq $true} | %{Get-ADUser $_.ObjectGuid} | select name, givenname, surname | export-csv c:\users\username\desktop\
-James
get-aduser -SearchBase
option might suit you.
option might suit you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
Specifies an Active Directory path to search under.
When you run a cmdlet from an Active Directory provider drive, the default value of this parameter is the current path of the drive.
When you run a cmdlet outside of an Active Directory provider drive against an AD DS target, the default value of this parameter is the default naming context of the target domain.
When you run a cmdlet outside of an Active Directory provider drive against an AD LDS target, the default value is the default naming context of the target LDS instance if one has been specified by setting the msDS-defaultNamingContext property of the Active Directory directory service agent (DSA) object (nTDSDSA) for the AD LDS instance. If no default naming context has been specified for the target AD LDS instance, then this parameter has no default value.
The following example shows how to set this parameter to search under an OU.
-SearchBase "ou=mfg,dc=noam,dc=corp,dc
"
From:: http://technet.microsoft.com/en-us/library/ee617247.aspx