7

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.

1 Answer 1

9
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 
2
  • Just perfect :) Thank you. I'll accept it as soon as serverfault allows me to Commented Feb 13, 2013 at 16:44
  • No problem. Glad I could help! Commented Feb 13, 2013 at 16:45

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.