Adding Addtional output on export csv

$Members=Get-ADObject -LDAPFilter ‘(name=*)’ -SearchBase $DN -server <Servername> | where {$_.Objectclass -notlike “organizational”} | select-object -Property name, distinguishedname, Objectclass

$membersDN | export-csv c:\temp\oumembers.csv -NoTypeInformation

The export-csv gives me the options as required, but also need the additional column for DN. Once I get the details, I will loop this out. For now I am checking how to add this additional column which will be same across.

Really? That’s nearly impossible. :wink: You save the query output in a variable $Members but you export a variable $membersDN. That shouldn’t work at all.

My bad it’s $members only. I was doing some R&D and paste the wrong one. The output gives the desired result, but need the additional column of DN

Hmmm … I’m pretty unsure if it’s just an inaccuracy in your wording. DN is short for Distinguished Name. And if your code works as you state it you already have a cloumn with the DN - it’s called “distinguishedname”.

You are operating on objects, use add-member to add


[pre]$a=get-process |select name,id,cpu
$b|%{$a[$i]|add-member line $;$i++}
]|add-member custom $_}