# Output Help

**URL:** https://forums.powershell.org/t/output-help/4076
**Category:** PowerShell Help
**Created:** [April 21, 2015, 6:47am UTC](https://forums.powershell.org/t/output-help/4076 "2015-04-21T06:47:08Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![lee-d](https://avatars.discourse-cdn.com/v4/letter/l/eb9ed0/32.png) [@lee-d](https://forums.powershell.org/u/lee-d)
#### Post date: [April 21, 2015, 6:47am UTC](https://forums.powershell.org/t/output-help/4076/1 "2015-04-21T06:47:08Z")

</div>

I have become decent at finding the AD data I need but when it comes to creating a spreadsheet with the information I find my knowledge totally inadequate to do what I want to do. I am hoping for some quick help and some helpful URL’s.

```
    When I run "Get-aduser MyID -Properties * | FL Name, Memberof " the memberof field has over 100 entries in curly braces separated by commas.
  I would like to end up with a spreadsheet with my name in one column and then another column of the 100+ groups, then the next users name, his groups etc.

```

I have looked at Format-List, and tried Exportto-csv with no luck, what is the best way to do this?

Thanks for any help you can provide,  
Lee

---

<div class="post-metadata">

### Author: ![donj](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/donj/32/137_2.png) [@donj](https://forums.powershell.org/u/donj)
#### Post date: [April 21, 2015, 6:54am UTC](https://forums.powershell.org/t/output-help/4076/2 "2015-04-21T06:54:02Z")

</div>

That’s because MemberOf is a collection of objects, not just a simple value; when asked to display a collection in a list or table, PowerShell can’t create a sub-list or sub-table, so it does the curly bracket thing.

There’s no straightforward way to get what you want using what’s built into the shell. You’d have to code up something custom.

---

<div class="post-metadata">

### Author: ![duffwv](https://avatars.discourse-cdn.com/v4/letter/d/f9ae1b/32.png) [@duffwv](https://forums.powershell.org/u/duffwv)
#### Post date: [April 21, 2015, 6:55am UTC](https://forums.powershell.org/t/output-help/4076/3 "2015-04-21T06:55:05Z")

</div>

```
Get-aduser MyID -Properties memberof |
Select-Object Name,@{n='groups';e={
		$_.memberof -join "`r`n"
	}} |
Export-CSV -NoTypeInformation -Path c:\test.csv
```
See if that is closer to what you want.
```
```

---

<div class="post-metadata">

### Author: ![duffwv](https://avatars.discourse-cdn.com/v4/letter/d/f9ae1b/32.png) [@duffwv](https://forums.powershell.org/u/duffwv)
#### Post date: [April 21, 2015, 7:02am UTC](https://forums.powershell.org/t/output-help/4076/4 "2015-04-21T07:02:08Z")

</div>

```
Get-aduser MyID -Properties memberof |
ForEach-Object {
	$name = $_.name
	$_.memberof |
	ForEach-Object {
		[pscustomobject]@{
			'Name'=$name
			'Group'=$_
		}
	}
} |
Export-Csv -NoTypeInformation -Path c:\test.csv
```
Or something like this.
```
```

---

<div class="post-metadata">

### Author: ![rob-simmers](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rob-simmers/32/1010_2.png) [@rob-simmers](https://forums.powershell.org/u/rob-simmers)
#### Post date: [April 21, 2015, 7:18am UTC](https://forums.powershell.org/t/output-help/4076/5 "2015-04-21T07:18:29Z")

</div>

Ugly, but it works…

Calculated Expression  
Loop through MemberOf  
Split the CN into an array  
Get the first index (e.g. CN=MyGroup)  
Replace CN= with nothing, basically strip off CN=  
And finally Join the returned array with a semicolon…

```
Get-ADUser myuser -Properties MemberOf | Select Name, @{Label="Groups";Expression={$($_.MemberOf | foreach{($_.Split(",")[0].Replace("CN=",""))}) -Join ";"}}
```

Returns:

```
Name Groups                                                                         
---- ------                                                                         
My User Group1;Group2;Group3;Group4;...
```

---

<div class="post-metadata">

### Author: ![lee-d](https://avatars.discourse-cdn.com/v4/letter/l/eb9ed0/32.png) [@lee-d](https://forums.powershell.org/u/lee-d)
#### Post date: [April 21, 2015, 7:22am UTC](https://forums.powershell.org/t/output-help/4076/6 "2015-04-21T07:22:45Z")

</div>

Thanks Don. I just purchased your PS in 30 days of lunches; does that include how I might handle this?

---

<div class="post-metadata">

### Author: ![lee-d](https://avatars.discourse-cdn.com/v4/letter/l/eb9ed0/32.png) [@lee-d](https://forums.powershell.org/u/lee-d)
#### Post date: [April 21, 2015, 7:23am UTC](https://forums.powershell.org/t/output-help/4076/7 "2015-04-21T07:23:53Z")

</div>

Output has a little extra info, how do I trim it down?

Name Dan, Lee  
Group CN=g-cae-NetworkEng-readers,OU=Roles,DC=up,DC=corp,DC=upc  
Name Dan, Lee  
Group CN=g-jar-read,OU=Roles,DC=up,DC=corp,DC=upc

---

<div class="post-metadata">

### Author: ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)
#### Post date: [May 16, 2024, 8:45pm UTC](https://forums.powershell.org/t/output-help/4076/8 "2024-05-16T20:45:28Z")

</div>


