locked
How to fetch all users from a particular company RRS feed

  • Question

  • Hello All:

    I am trying to get the report of all the users under my Company with the below command:
    get-aduser -properties Company -filter {Company -like "<<My Company Name>>"} | Export-Csv -Path "D:\FolderA\Users.csv"

    With the above command, I am able to get only 35 records.
    How to fetch all the users.

    Above in query I have mentioned like <<My Company Name>>. Here I can refer my company name.
    Ex: Infosys


    Prakash Mallela

    Monday, December 17, 2018 9:13 AM

All replies

  • Is the  name always spelled exactly the same?  With LIKE you need to use a wildcard character to get a correct match.


    \_(ツ)_/

    Monday, December 17, 2018 9:26 AM
  • Yes, I have spelled it correctly. With the query mentioned above I was able to get for both the cases as in "INFOSYS" or "Infosys".
    In my result, I have observed that Distinguished name is like this:
    "OU=UserAccounts,DC=redmond,DC=corp,DC=microsoft,DC=com"

    I believe we have fareast accounts also.

    How can I get both redmond and fareast account users.

    Prakash Mallela

    Monday, December 17, 2018 9:59 AM
  • We cannot see you AD and we cannot verify your attribute settings.  If the match fails then you have issues.  "Spelling" includes extra spaces.  The matches are NOT case sensitive.  It is up to you to figure out why this is happening.  It is not a scripting issue.


    \_(ツ)_/

    Monday, December 17, 2018 10:05 AM
  • As noted, use either:

    -Filter {Company -Like "*Infosys*"}

    or

    -Filter {Company -eq "infosys"}

    Neither is case sensitive. Since the company attribute is not in the Global Catalog, if you have more than one domain, you need to use a separate query for each. Use the -Server parameter of the cmdlet to target a domain controller in each domain.


    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    Monday, December 17, 2018 10:50 AM
  • Assuming the company has multiple domains but ..

    Why would the following be a Microsoft name?

    "OU=UserAccounts,DC=redmond,DC=corp,DC=microsoft,DC=com"

    Are you in a Microsoft office that is located I  Redmond?  Are you trying to get all employees at all of Microsoft that are assigned *Infosys* as a company name?

    To much confusing information.

    If Richard is correct then you need to find every domain that is in your company forest.


    \_(ツ)_/

    Monday, December 17, 2018 11:00 AM
  • Hi,

    Was your issue resolved?

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.

    If no, please reply and tell us the current situation in order to provide further help.

    Best Regards,

    Lee


    Just do it.

    Monday, December 24, 2018 2:53 AM