Created
September 20, 2025 00:38
-
-
Save jschlackman/18426bd786994561f152487e30479b27 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Retrieves all mailboxes from Exchange that have automatic forwarding configured at the mailbox level. | |
.DESCRIPTION | |
Author: James Schlackman <[email protected]> | |
Last Modified: Sep 19 2025 | |
.PARAMETER OutputPath | |
Path to optional CSV export file. | |
#> | |
#Requires -Modules ExchangeOnlineManagement | |
Param( | |
# Export file name | |
[Parameter()] [ValidateNotNullOrEmpty()] [String]$OutputPath = ('{0:yyMMdd} Forwarded Mailboxes.csv' -f (Get-Date)) | |
) | |
Import-Module ExchangeOnlineManagement | |
# Connect to Exchange Online if not already connected | |
If (!(Get-ConnectionInformation)) { | |
Connect-ExchangeOnline | |
} | |
$allFwds = Get-Mailbox -Filter {ForwardingAddress -ne $null -or ForwardingSmtpAddress -ne $null} | |
$resultOutput = $allFwds | Select DisplayName,Alias,RecipientTypeDetails,Identity,ForwardingAddress,ForwardingSmtpAddress | |
# Show in grid | |
Write-Host 'See grid export for details and select records for export.' | |
$resultExport = $resultOutput | Out-GridView -OutputMode Multiple -Title 'Select records for export to CSV' | |
# Export selected records to file | |
If ($resultExport) { | |
Write-Host 'Exporting to ' -NoNewline | |
Write-Host $OutputPath -ForegroundColor Green | |
$resultExport | Export-Csv -NoTypeInformation -Path $OutputPath -Encoding UTF8 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment