Avatar of AhmedAliShaik
AhmedAliShaik
Flag for India asked on

Script for getting AD user information

Team,

I need to get the list of AD users in my domain with a criteria. If the custom attribute 1 and 5 are equal i should get the total number of users count.

get-user -Resultsize unlimited -organizationalunit mydomain.com/Users -filter {((customAttribute6 -like '76*') -and (customAttribute6 -like 'Vehicle*'))}| Measure-Object).Count

When executing the count i am getting the below error:

The term 'customAttribute6' is not recognized as the name of a cmdlet, function
, script file, or operable program. Check the spelling of the name, or if a pat
h was included, verify that the path is correct and try again.
At line:1
+ get-user -resultsize unlimited -OrganizationalUnit mydomain.com/users -Filter
(customAttribute6 <<<<  -like '76*')
    + CategoryInfo          : ObjectNotFound: (customAttribute1:String) [], Co
   mmandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Is there a way i can use custom attribute to retrieve AD users list.

Please help me in executing the cmd.

Thanks in Advance.
Shell ScriptingActive Directory

Avatar of undefined
Last Comment
AhmedAliShaik

8/22/2022 - Mon
SOLUTION
Krzysztof Pytko

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
AhmedAliShaik

ASKER
Krzysztof ,

I will try this and post u with updates.
AhmedAliShaik

ASKER
Hi Krzysztof ,

I believe Get-ADuser is a Quest cmdlet.

I am able to resolve only get-user even no luck with the command.

Can u revise and give me a windows/Exchange powershell command for the same.
Krzysztof Pytko

No, Get-ADUser is a Windows Server 2008R2 PowerShell module for AD. Do you have 2008R2 DC ? If not, which PowerShell version do you use ?

Krzysztof
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
ASKER CERTIFIED SOLUTION
Krzysztof Pytko

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
AhmedAliShaik

ASKER
Thanks you.