Mark Minasi's Tech Forum
Sign up Calendar Latest Topics
 
 
 


Reply
  Author   Comment  
Phil-n-JaxFL

Avatar / Picture

Grumpy Old Men
Registered:
Posts: 87
Reply with quote  #1 
I run this script:

foreach ($group in Get-DistributionGroup) { get-distributiongroupmember $group | ft @{expression={$_.displayname};Label=”$group”}}

and the output on the screen is over 50 Distribution Groups with the users.

I modify the script to this:

foreach ($group in Get-DistributionGroup) { get-distributiongroupmember $group | ft @{expression={$_.displayname};Label=”$group”} | Export-Csv C:\Users\admin-probeson\Desktop\DLgroupMbrs.txt}

And I get this:

#TYPE Microsoft.PowerShell.Commands.Internal.Format.FormatStartData
"ClassId2e4f51ef21dd47e99d3c952918aff9cd","pageHeaderEntry","pageFooterEntry","autosizeInfo","shapeInfo","groupingEntry"
"033ecb2bc07a4d43b5ef94ed5a35d280",,,,"Microsoft.PowerShell.Commands.Internal.Format.TableHeaderInfo",
"9e210fe47d09416682b841769c78b8a3",,,,,
"27c87ef9bbda4f709f6b4002fa4af63c",,,,,
"27c87ef9bbda4f709f6b4002fa4af63c",,,,,
"27c87ef9bbda4f709f6b4002fa4af63c",,,,,
"27c87ef9bbda4f709f6b4002fa4af63c",,,,,
"27c87ef9bbda4f709f6b4002fa4af63c",,,,,
"27c87ef9bbda4f709f6b4002fa4af63c",,,,,
"27c87ef9bbda4f709f6b4002fa4af63c",,,,,
"4ec4f0187cb04f4cb6973460dfe252df",,,,,
"cf522b78d86c486691226b40aa69e95c",,,,,

I can't see what I'm doing wrong...can someone please help. Thanks.


__________________
Phil
0
jsclmedave

Administrator
Registered:
Posts: 506
Reply with quote  #2 
Quote:
Originally Posted by Phil-n-JaxFL
I run this script:

foreach ($group in Get-DistributionGroup) { get-distributiongroupmember $group | ft @{expression={$_.displayname};Label=”$group”}}

and the output on the screen is over 50 Distribution Groups with the users.

I modify the script to this:

foreach ($group in Get-DistributionGroup) { get-distributiongroupmember $group | ft @{expression={$_.displayname};Label=”$group”} | Export-Csv C:\Users\admin-probeson\Desktop\DLgroupMbrs.txt}

And I get this:

#TYPE Microsoft.PowerShell.Commands.Internal.Format.FormatStartData
"ClassId2e4f51ef21dd47e99d3c952918aff9cd","pageHeaderEntry","pageFooterEntry","autosizeInfo","shapeInfo","groupingEntry"
"033ecb2bc07a4d43b5ef94ed5a35d280",,,,"Microsoft.PowerShell.Commands.Internal.Format.TableHeaderInfo",
"9e210fe47d09416682b841769c78b8a3",,,,,
"27c87ef9bbda4f709f6b4002fa4af63c",,,,,
"27c87ef9bbda4f709f6b4002fa4af63c",,,,,
"27c87ef9bbda4f709f6b4002fa4af63c",,,,,
"27c87ef9bbda4f709f6b4002fa4af63c",,,,,
"27c87ef9bbda4f709f6b4002fa4af63c",,,,,
"27c87ef9bbda4f709f6b4002fa4af63c",,,,,
"27c87ef9bbda4f709f6b4002fa4af63c",,,,,
"4ec4f0187cb04f4cb6973460dfe252df",,,,,
"cf522b78d86c486691226b40aa69e95c",,,,,

I can't see what I'm doing wrong...can someone please help. Thanks.



May be a typo but you have a } after TXT and you exporting to TXT not CSV
and your using FT still..?


foreach ($group in Get-DistributionGroup) { get-distributiongroupmember $group | ft @{expression={$_.displayname};Label=”$group”} | Export-Csv C:\Users\admin-probeson\Desktop\DLgroupMbrs.txt}



See if this works for you 


$Groups = Get-DistributionGroup | Select Name
Foreach ($Group in $Groups) {Get-DistributionGroupMember $group | Select-Object Name,@{expression={$_.displayname};Label=”$group”} | Export-Csv C:\Users\admin-probeson\Desktop\DLgroupMbrs.CSV -NoTypeInformation -Append






__________________
Tim Bolton @jsclmedave
Email: [string](0..20|%{[char][int](32+('527377347976847978324785847679797514357977').substring(($_*2),2))}) -replace ' '  

New to the forum? Please Read this
0
Phil-n-JaxFL

Avatar / Picture

Grumpy Old Men
Registered:
Posts: 87
Reply with quote  #3 
I got an error on every one:

Cannot process argument transformation on parameter 'Identity'. Cannot convert value "@{Name=MM-DailyCheckout}" to
type "Microsoft.Exchange.Configuration.Tasks.DistributionGroupMemberIdParameter". Error: "Cannot convert hashtable to
an object of the following type: Microsoft.Exchange.Configuration.Tasks.DistributionGroupMemberIdParameter.
Hashtable-to-Object conversion is not supported in restricted language mode or a Data section."
+ CategoryInfo : InvalidData: ([smile] [Get-DistributionGroupMember], ParameterBindin...mationException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Get-DistributionGroupMember
+ PSComputerName : eihqmail1.ei.local

I ran this command: 
Foreach ($Group in $Groups) {Get-DistributionGroupMember $Group | Select-Object Name,@{expression={$_.displayname};Label=”$Group”} | Export-Csv C:\Users\admin-probeson\Desktop\DLgroupMbrs.CSV -NoTypeInformation -Append}


__________________
Phil
0
Phil-n-JaxFL

Avatar / Picture

Grumpy Old Men
Registered:
Posts: 87
Reply with quote  #4 
Anyone have any ideas?


__________________
Phil
0
wkasdo

Avatar / Picture

Administrator
Registered:
Posts: 241
Reply with quote  #5 
The problem is the FT; this is a formatting statement, while you are just looking to get the data out. Formatting is something you do at the very end of a pipeline, not in the middle. Try something like this (not tested, don't have Exchange in my lab):


foreach ($group in Get-DistributionGroup)
{
     get-distributiongroupmember $group | ForEach-Object { [PSCustomObject] @{group=$group; member=$_.displayname}} | Export-Csv C:\Users\admin-probeson\Desktop\DLgroupMbrs.txt
}



__________________
[MSFT]; Blog: https://blogs.technet.microsoft.com/389thoughts/
0
Phil-n-JaxFL

Avatar / Picture

Grumpy Old Men
Registered:
Posts: 87
Reply with quote  #6 
wkasdo: that gave no output at all (not sure why).

However, I figured this out last night and it worked:

foreach ($group in Get-DistributionGroup) {Get-DistributionGroupMember $Group | ft @{expression={$_.displayname};Label=”$group”} | Out-File c:\Users\admin-probeson\desktop\DLgroupMbrs.txt -Append}

Thanks to both of you for helping!!

__________________
Phil
0
jsclmedave

Administrator
Registered:
Posts: 506
Reply with quote  #7 
Phil,  I emailed you a script.  Did it work for you?
__________________
Tim Bolton @jsclmedave
Email: [string](0..20|%{[char][int](32+('527377347976847978324785847679797514357977').substring(($_*2),2))}) -replace ' '  

New to the forum? Please Read this
0
Phil-n-JaxFL

Avatar / Picture

Grumpy Old Men
Registered:
Posts: 87
Reply with quote  #8 
No, jsclmedave, it did not. Nor did wkasdo's. The one I figured out last night, and posted in my above posting, however, did. But, thanks for helping...both scripts got me trying different things.
__________________
Phil
0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.