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.
This topic is 3 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
Lembasts
Posts: 406
Last visit: Mon Apr 15, 2024 3:12 pm
Has voted: 1 time
Been upvoted: 1 time

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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 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: 406
Last visit: Mon Apr 15, 2024 3:12 pm
Has voted: 1 time
Been upvoted: 1 time

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.
This topic is 3 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked