I am running a report on our users and fashioning a nice clean report listing the Name of their OU, among other parameters.
All companies have a root ou called ‘Hosted’ and then there are about 100 SubOU’s from within. I want to iterate through each OU and then loop through each user to output an object of ‘OU’, ‘user’, etc…
To first get my list of OU’s, I execute this command.
Hmmm … I assume you want to create this report for all of your ‘Hosted’-OUs and their users anyway, right? Why bother to create a sophisticated query? You could simply query all users from your AD strucrure along with their “CanonicalName” - and of course the other parameters you’re after. When you sort this list by CanonicalName you’re almost done with it. The rest is a little string acrobatics or Excel formatting.
That’s what I meant. If the “Hosted”-OUs are all on the same “level” in your AD it’s a piece of cake to extract this bit of information from the CanonicalName.
Need to capture all of these users and their attributes and list the OU that each is attributed along with other attributes.
Name
OU
User1_1
Company1_OU
User2_1
Company1_OU
User3_1
Company1_OU
User1_2
Company2_OU
User2_2
Company2_OU
User3_2
Company2_OU
User1_2A
Company2A_OU
User2_2A
Company2A_OU
User3_2A
Company2A_OU
User1_3
Company3_OU
User2_3
Company3_OU
User3_3
Company3_OU
My original command was to first capture all of the OU’s within the HOsted OU…recursively to capture the subOUs (example Company_2A).
My original command was to declare my ‘Hosted’ OU and then the subtree parameter to recursively grab the subou’s, however the root OU appears in the list.
[quote quote=222687]My original command was to first capture all of the OU’s within the HOsted OU…recursively to capture the subOUs (example Company_2A).
My original command was to declare my ‘Hosted’ OU and then the subtree parameter to recursively grab the subou’s, however the root OU appears in the list.[/quote]
OK, but if I got this right that would be a manual process anyway, right.
If you have 2 levels where to find relevant information in your OU structure you could use this …