Forum Discussion
Trell627
May 14, 2024Copper Contributor
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
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
- LainRobertsonSilver Contributor
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
- Trell627Copper ContributorThank you!