Link to home
Start Free TrialLog in
Avatar of MilesLogan
MilesLoganFlag for United States of America

asked on

Export data from the notes field from multiple AD groups with powershell

Hi EE

I think I need to use the -ExpanProperty option here somewhere but I cant figure it out.. I need to export ALL the data in the notes
section for a list of AD groups .. but I can only get it to output the first line in the notes of the group .

can someone assist please ..

gc groups.txt | Get-ADGroup -Properties name,info | select name,info | Export-Csv GroupInfo.csv -NoTypeInformation
Avatar of Rainer Jeschor
Rainer Jeschor
Flag of Germany image

Hi,

could you please try the following?
I assume that the notes property is simply a string array, therefore you have to join the single lines.
Sorry, I have currently no domain connectivity to test/verify:
gc groups.txt | Get-ADGroup -Properties name,info | select name,info,@{Name='Notes';Expression={[string]::join(" ", ($_.Notes)) | Export-Csv GroupInfo.csv -NoTypeInformation 

Open in new window


HTH
Rainer
Avatar of MilesLogan

ASKER

Hi Rainer , I could not figure out where its missing ..

Missing closing '}' in statement block.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : MissingEndCurlyBrace
ASKER CERTIFIED SOLUTION
Avatar of Rainer Jeschor
Rainer Jeschor
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Rainer ... it outputs a notes column but not exactly what I need .

so the info attribute is the "notes" field in the AD group .. I need to be able to export all that data.
check out the screen shot , currently I can only get it to output to CSV the first line of data in the Notes field.
Capture.PNG
Thanks Rainer .. from your assistance I modified it a tad and it worked .. thanks !


gc groups.txt | Get-ADGroup -Properties name,info | select name,@{Name='Info';Expression={[string]::join(" ", ($_.Info))}} | Export-Csv GroupsInfoFull.csv -NoTypeInformation