tags:

views:

245

answers:

1

I'm using the Quest AD cmdlets, particularly Get-QADUser, to pull a list of users from AD and return just a few attributes. No problems, easy enough, but I want to transform one of the properties (parentContainerDN) before exporting to CSV.

Get-QADUser -name "Froosh" | Select-Object logonName,homeDrive,parentContainerDN | Export-CSV C:\Temp\File.csv

This works of course, but the parentContainerDN is long and untidy. Is there an easy way to replace that with parentContainerDN.Name before passing that to Export-CSV?

I'd be happy with a commandline solution, or a script snippet.

Thanks!

+3  A: 

There's a special syntax to create on-the-fly properties in select-object. Try this (wrapping added for clarity):

get-qaduser -name "hamilmat" 
    | select-object logonName, homeDrive, 
        @{Name="containerName"; Expression={$_.parentContainerDN.Name}} 
    | export-csv ...
Matt Hamilton