Filtering Enabled only Get-ADObject to with specific patterns and OU?

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
jvierra
Posts: 14691
Joined: Tue May 22, 2007 9:57 am
Answers: 7
Has voted: 2 times
Been upvoted: 5 times

Re: Filtering Enabled only Get-ADObject to with specific patterns and OU?

Post by jvierra »

You asked this same question in another forum. The answer given gave you the steps to diagnosing why you were not getting any results. Have you done what was requested. Do you get result when retrieving without the "Where" filter?

User avatar
Lembasts
Posts: 320
Joined: Thu Mar 15, 2012 9:47 am

Re: Filtering Enabled only Get-ADObject to with specific patterns and OU?

Post by Lembasts »

I'd use an ldapfilter

Code: Select all

get-adobject -LDAPFilter '(&(objectclass=user)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))'
The above will get enabled user and computer accounts.
Cheers
David

jvierra
Posts: 14691
Joined: Tue May 22, 2007 9:57 am
Answers: 7
Has voted: 2 times
Been upvoted: 5 times

Re: Filtering Enabled only Get-ADObject to with specific patterns and OU?

Post by jvierra »

Lembasts wrote:
Thu Sep 03, 2020 10:46 pm
I'd use an ldapfilter

Code: Select all

get-adobject -LDAPFilter '(&(objectclass=user)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))'
The above will get enabled user and computer accounts.
Cheers
David
That is what he asked before and the answer was given. The answer does not produce results.
User account control will not work in this case and the query will not produce the desired results.

User avatar
Lembasts
Posts: 320
Joined: Thu Mar 15, 2012 9:47 am

Re: Filtering Enabled only Get-ADObject to with specific patterns and OU?

Post by Lembasts »

I use useraccountcontrol all the time and it works fine.

Locked