PowerShell - finding users who are Inactive AND not disabled
Solution 1:
The Search-ADAccount
does not accept a parameter -Filter
. Please see the Technet docs or Get-Help Search-ADAccount
for a list of supported parameters.
You can pipe the results of the search to Where-Object
to get only enabled users:
Search-ADAccount -UsersOnly -SearchBase "ou=FirstOU,dc=domain,dc=com" -AccountInactive -TimeSpan 30 |
Where-Object { $_.Enabled -eq $true }
Solution 2:
Filter it the other way?:
Search-ADAccount -UsersOnly -AccountInactive -TimeSpan 30.00:00:00 |where {$_.enabled}