none
Get-DistributionGroupMember | I need the result in two separate Columns RRS feed

  • Question

  • Hi,

    How can expand the result to two columns instead of the whole result in one raw?

    Get-DistributionGroup -ResultSize Unlimited -Identity "Academic Staff"
    | Get-DistributionGroupMember | Select Name, PrimarySmtpAddress  | Export-Csv -Path C:\
    Scripts\AllStaff-DG.csv -NoTypeInformation

    The result of this comes in single raw.

    Thanks,

    Monday, June 24, 2013 8:05 AM

Answers

  • End up having this to fully automate the things for me with task Scheduler. 

    Created another batch script to run the PowerShell.ps1 script.

    Powershell -command "& {C:\Scripts\PowerShell.ps1 }"
    Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin
    Get-DistributionGroupMember "DG Group Name" | Select Name, PrimarySmtpAddress | Export-Csv -Path c:\Scripts\DGName.csv -NoTypeInformation
    Send-MailMessage -From me@domain.com -To rec@domain.com -cc helpdesk@OurDOmain.com  -Subject "All Staff" -SmtpServer HUBServer01 -Attachments c:\Scripts\DGName.csv

    Hope someone else will benefit.

    Thanks,

    • Marked as answer by hms_24 Tuesday, June 25, 2013 10:27 AM
    Tuesday, June 25, 2013 10:26 AM
  • Hi Rich,with the above answered post, the issue is sorted out.

    End up having this to fully automate the things for me with task Scheduler. 

    Created another batch script to run the PowerShell.ps1 script.

    Powershell -command "& {C:\Scripts\PowerShell.ps1 }"
    Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin
    Get-DistributionGroupMember "DG Group Name" | Select Name, PrimarySmtpAddress | Export-Csv -Path c:\Scripts\DGName.csv -NoTypeInformation
    Send-MailMessage -From me@domain.com -To rec@domain.com -cc helpdesk@OurDOmain.com  -Subject "All Staff" -SmtpServer HUBServer01 -Attachments c:\Scripts\DGName.csv

    Hope someone else will benefit.

    • Marked as answer by hms_24 Wednesday, June 26, 2013 8:13 AM
    Wednesday, June 26, 2013 8:13 AM

All replies

  • Hi,

    This script is already shows the result in a two columns


    Regards from ExchangeOnline.in|Windows Administrator Area

    Monday, June 24, 2013 10:47 AM
  • hi,

    but if you select the raw, it you will see both Name & email address in the one raw rather than being split each column separately.

    Monday, June 24, 2013 10:56 AM
  • Hi,

    This gives in one raw;instead of spiliting  each result in separate column.

    Name                       PrimarySmtpAddress                        


    Monday, June 24, 2013 11:08 AM
  • Hi,

    I am not sure, why this is happening this way for you. Following is the result I obtained in my lab:


    Regards from ExchangeOnline.in|Windows Administrator Area

    Monday, June 24, 2013 12:09 PM
  • hehehe... Then why its happening with me like that?

    Monday, June 24, 2013 12:10 PM
  • What version of Excel you are using?
    Monday, June 24, 2013 12:11 PM
  • This the screen shot of the result I get, all the fields result are in Raw by Raw
    Monday, June 24, 2013 12:14 PM
  • This the screen shot of the result I get, all the fields result are in Raw by Raw

    Open the CSV file in notepad. Are the columns separated by commas?

    If you start Excel and then open the file is the delimiter a comma? If not, what happens if you select "comma" as the delimiter?


    --- Rich Matheisen MCSE&I, Exchange MVP

    Tuesday, June 25, 2013 2:16 AM
  • Hello Rich,

    Thanks for your reply.

    I opened the file with Notepad, there are no commas between the two columns.

    The file type is : Microsoft Comma Separated Values File.

    Any further help?

    Tuesday, June 25, 2013 5:07 AM
  • If I do with | Export-Csv C:\Scripts\FileName.csv I get the below;


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


    Tuesday, June 25, 2013 5:23 AM
  • End up having this to fully automate the things for me with task Scheduler. 

    Created another batch script to run the PowerShell.ps1 script.

    Powershell -command "& {C:\Scripts\PowerShell.ps1 }"
    Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin
    Get-DistributionGroupMember "DG Group Name" | Select Name, PrimarySmtpAddress | Export-Csv -Path c:\Scripts\DGName.csv -NoTypeInformation
    Send-MailMessage -From me@domain.com -To rec@domain.com -cc helpdesk@OurDOmain.com  -Subject "All Staff" -SmtpServer HUBServer01 -Attachments c:\Scripts\DGName.csv

    Hope someone else will benefit.

    Thanks,

    • Marked as answer by hms_24 Tuesday, June 25, 2013 10:27 AM
    Tuesday, June 25, 2013 10:26 AM
  • Hello Rich,

    Thanks for your reply.

    I opened the file with Notepad, there are no commas between the two columns.

    The file type is : Microsoft Comma Separated Values File.

    Any further help?

    That's pretty unusual.

    What happens if you add this to your export-csv?

    -Delimiter ','

    Do you get the commas as separators?

    --- Rich Matheisen MCSE&I, Exchange MVP

    Wednesday, June 26, 2013 2:45 AM
  • Hi Rich,with the above answered post, the issue is sorted out.

    End up having this to fully automate the things for me with task Scheduler. 

    Created another batch script to run the PowerShell.ps1 script.

    Powershell -command "& {C:\Scripts\PowerShell.ps1 }"
    Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin
    Get-DistributionGroupMember "DG Group Name" | Select Name, PrimarySmtpAddress | Export-Csv -Path c:\Scripts\DGName.csv -NoTypeInformation
    Send-MailMessage -From me@domain.com -To rec@domain.com -cc helpdesk@OurDOmain.com  -Subject "All Staff" -SmtpServer HUBServer01 -Attachments c:\Scripts\DGName.csv

    Hope someone else will benefit.

    • Marked as answer by hms_24 Wednesday, June 26, 2013 8:13 AM
    Wednesday, June 26, 2013 8:13 AM