Forum Discussion

Trell627's avatar
Trell627
Copper Contributor
May 14, 2024
Solved

How to modify script to export results to CSV:

How to modify script to export results to CSV:

 

Get-Mailbox | Where {$null -ne $_.ForwardingSmtpAddress} | FT UserPrincipalName,ForwardingSmtpAddress,DeliverToMailboxAndForward

  • Trell627 

     

    Hi, LeTrell.

     

    You need to replace the "FT" (alias for Format-Table) with Select-Object, after which you can pipe to a CSV file using Export-Csv.

     

    Get-Mailbox |
        Where {$null -ne $_.ForwardingSmtpAddress} |
            Select-Object -Property UserPrincipalName,ForwardingSmtpAddress,DeliverToMailboxAndForward |
                Export-Csv -Path "D:\Data\Temp\myExchangeData.csv" -NoTypeInformation;

     

    Cheers,

    Lain

2 Replies

  • LainRobertson's avatar
    LainRobertson
    Silver Contributor

    Trell627 

     

    Hi, LeTrell.

     

    You need to replace the "FT" (alias for Format-Table) with Select-Object, after which you can pipe to a CSV file using Export-Csv.

     

    Get-Mailbox |
        Where {$null -ne $_.ForwardingSmtpAddress} |
            Select-Object -Property UserPrincipalName,ForwardingSmtpAddress,DeliverToMailboxAndForward |
                Export-Csv -Path "D:\Data\Temp\myExchangeData.csv" -NoTypeInformation;

     

    Cheers,

    Lain