locked
Get only SamAccountname get-aduser RRS feed

  • Question

  • Hello scripting guys

    I'm trying to bring all username from our domain, but the script takes to long get-aduser -filterI've google it for a possible solution to this and found some script with and also using the S.DS.P module but I'm still trying to figure how to use them.

    Do you know if there is any when to populate a variable with them, by doing a search that starts bringing the 500 first, then 501 to 1000.....? doing this, the search will take a couple of seconds and will be possible to add a job that populates an array to do a search.   


    • Edited by D.M.L Thursday, March 21, 2019 3:26 PM
    Thursday, March 21, 2019 3:11 PM

Answers

  • That's not an script found on internet, get-aduser -filter * its a MS module, but its ok, i was just trying to find a way to do a custom search delimited.

    I'll close the question, thanks anyway.

    • Marked as answer by D.M.L Thursday, March 21, 2019 3:41 PM
    Thursday, March 21, 2019 3:41 PM

All replies

  • Please disable your grammarly and fix your post. It's pertty much unreadable.

    Live long and prosper!

    (79,108,97,102|%{[char]$_})-join''

    Thursday, March 21, 2019 3:19 PM
  • I't was disable, sorry don't know why it set it like it. I have correct the post.

    Thursday, March 21, 2019 3:27 PM
  • We do not support scripts found at the internet. If you have issues or questions regarding scripts you've found you should contact the author.

    Querying some couple hundrets or a thousand accounts from an Active Directory usually does not take that long. You might find something better (newer) in the PowershellGallery.


    Live long and prosper!

    (79,108,97,102|%{[char]$_})-join''


    • Edited by BOfH-666 Thursday, March 21, 2019 3:34 PM
    Thursday, March 21, 2019 3:33 PM
  • That's not an script found on internet, get-aduser -filter * its a MS module, but its ok, i was just trying to find a way to do a custom search delimited.

    I'll close the question, thanks anyway.

    • Marked as answer by D.M.L Thursday, March 21, 2019 3:41 PM
    Thursday, March 21, 2019 3:41 PM
  • That's not an script found on internet, get-aduser -filter * its a MS module, but its ok, i was just trying to find a way to do a custom search delimited.

    I'll close the question, thanks anyway.

    You wrote in your initial post that you've found some script after googling ... If it's code you wrote you should post it here (formatted as code please) as we cannot know what your code looks like. ;-)

    And please do not mark something as the answer if it is not really an answer. Thanks


    Live long and prosper!

    (79,108,97,102|%{[char]$_})-join''

    Thursday, March 21, 2019 3:51 PM
  • I said found, not that using it, I've say it just as examples, my question was other, and yes, if i try to search 8k of users the report takes more than 20 min, and i'm only asking for SamAccountNames 
    Thursday, March 21, 2019 3:56 PM
  • Get-AdUser -Filter * | Select SamAccountName

    You need to learn basic PowerShell before trying to ask questions in a technical forum.


    \_(ツ)_/

    Thursday, March 21, 2019 6:03 PM
  • and you need to know the correct answer. Did you try to run the same script that i just ask you, and post , for a domain that contains more than 8000 users? 

    PS: once it finish i'll give you the measure result.

     

    Thursday, March 21, 2019 6:19 PM
  • Did you try to run the same script that i just ask you,

    I might missed something  but until now you did not post any script at all.

    Just as an example: I have access to two real live domains and ran this code on both ...

    Measure-Command -Expression {
    $AllUsers = Get-ADUser -Filter *
    }
    $AllUsers.Count

    The first took about 7 seconds and shows 1450 users. The second took about 60 second while it shows 13883 users collected from a forest with a few domains spread across Europe.

    So if your code takes 20 minutes for 8000 users there might be something wrong either with your code or with your infrastructure.


    Live long and prosper!

    (79,108,97,102|%{[char]$_})-join''

    Friday, March 22, 2019 2:23 AM