Link to home
Start Free TrialLog in
Avatar of ivan rosa
ivan rosaFlag for United States of America

asked on

Adding a filter to a property

Hi Folks,

i have wrote this line here to get a count of all users from an OU
(Get-ADUser -Filter "objectcategory -eq 'user'" -SearchBase "OU=microsoft=com").count

Open in new window


however i'm also trying to add a filter where it would only select active users... this line here i know will pick this specifici object but I don't know how to tell it just to pick the ones that are active
(Get-ADUser -Filter "objectcategory -eq 'user'" -SearchBase "ou=microsoft=com" -properties * | select-object enabled).count

Open in new window


does anybody have any idea on how to accompllish it?

thanks for looking
Avatar of footech
footech
Flag of United States of America image

What do you mean by active?  Enabled?
(Get-ADUser -Filter "Enabled -eq '$true'" -SearchBase "OU=microsoft=com").count

Open in new window

The "objectcategory -eq 'user'" is redundant, since we're using the Get-ADUser cmdlet.
SOLUTION
Avatar of ivan rosa
ivan rosa
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ivan rosa

ASKER

Makes sense, thanks bud!
Glad to help.