Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm working on a set of script that will be used to migrate the users and structure from one active directory to another. For this, I'm using the Get-ADOrganizationalUnit commandlet to export the OUs like this:

Get-ADOrganizationalUnit -SearchBase $filterbase -filter * | export-csv $outcsv 

As it turns out, we have useful information stored in the "description" attribute of the source OUs. Unfortunately, it doesn't seem that this information is part of the data exported by the Get-ADOrganizationalUnit commandlet.

So, could anyone suggest a way in which I could get the same information from the source AD but including the Description ?

In truth, I can work very well if the only attributes I get back are DistinguishedName, name and description so if you have another way to list all OUs under a specific OU in AD that includes these attributes, (and can be piped to export-csv), it'll work as well.

share|improve this question

1 Answer 1

up vote 7 down vote accepted
Get-ADOrganizationalUnit -SearchBase $filterbase -filter * -Properties Description| export-csv $outcsv 

Should be what you're looking for. In almost all cases, if you want additional properties returned, then -Properties followed by a comma separated list of the additional properties is what you're looking for.

If you only want the three attributes that you mention in your question, then do something like:

Get-ADOrganizationalUnit -filter * -Properties Description | select-object name,distinguishedname,description | export-csv $outcsv
share|improve this answer
    
Just perfect :) Thank you. I'll accept it as soon as serverfault allows me to –  Stephane Feb 13 '13 at 16:44
    
No problem. Glad I could help! –  MDMarra Feb 13 '13 at 16:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.