Grabbing all OU’s while ignoring their all sub-OU’s

Tags:
Active Directory
I am working on a project where we grab all useful user data from the AD/all OUs. We are doing this in order to move a user if they are in the wrong OU. For this we want to ignore all sub-OU in every OU, we also want to do this with out hard coding in a bunch of -nolike statements as we have many sub-OU. From my time researching this it looks like the only way to do this is through hard coding. Is there a way of, when searching through AD, ignoring ALL sub-ou and just searching all OU. Thanks for any help, Nicholas
0

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • ToddN2000
    What command are you using ?

    131,645 pointsBadges:
    report
  • BroadIntern
    Currently in our power shell script we are using 
    get-ADComputer -Filter '*' -Searchbase $ou -properties * | Select-object var,var,var
    the issue with this being if we want to block sub-ou process by name it searches through the whole of AD for each sub-ou we specify 
    15 pointsBadges:
    report
  • Subhendu Sen

    You can list or exclude all users accounts that are only enabled in the same domain.

    137,090 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: