-
Notifications
You must be signed in to change notification settings - Fork 2
/
CrossTenantMigration-Report.ps1
39 lines (34 loc) · 2.46 KB
/
CrossTenantMigration-Report.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<#
.DESCRIPTION
Run this in your source ExchangeOnline PowerShell environment.
This script exports the source information needed for the Cross-Tenant migration preview. It exports the following fields; DisplayName, PrimarySmtp,
ExchangeGuid (these must match when creating the mailusers), LegacyExchangeDN, and ArvhiveGuid (if archiving is enabled on the source box). Lastly,
it will export any additional X500 addresses on the source box (these must also be cloned over).
The source CSV is any CSV containing the source users UserPrincipalName in a column with the header named UPN. Get this via Admin Center > Users > Export.
.NOTES
Name: CrossTenantMigration-Report.ps1
Author: [email protected]
Version: 1.1
DateCreated: AUG 2023
#>
$csv = Import-CSV C:\Temp\YourUsersExportFrom365.csv
$csv | ForEach-Object {
$DisplayName = Get-Mailbox -Identity $_.UPN | Select-Object DisplayName -ExpandProperty DisplayName
$PrimarySmtp = Get-Mailbox -Identity $_.UPN | Select-Object PrimarySmtpAddress -ExpandProperty PrimarySmtpAddress
$DestinationSmtp = "[email protected]"
$ExchangeGUID = Get-Mailbox -Identity $_.UPN | Select-Object ExchangeGuid -ExpandProperty ExchangeGuid
$LegacyExchangeDN = Get-Mailbox -Identity $_.UPN | Select-Object LegacyExchangeDN -ExpandProperty LegacyExchangeDN
$ArchiveGuid = Get-Mailbox -Identity $_.UPN | Select-Object ArchiveGuid -ExpandProperty ArchiveGuid
$AdditionalX500 = Get-Mailbox -Identity $_.UPN | Select-Object EmailAddresses -ExpandProperty EmailAddresses | where {$_ -match 'X500'}
$AdditionalX500Array = $AdditionalX500 -join ";"
$report = New-Object psobject
$report | Add-Member -MemberType NoteProperty -name 'DisplayName' -Value $DisplayName
$report | Add-Member -MemberType NoteProperty -name 'PrimarySmtp' -Value $PrimarySmtp
$report | Add-Member -MemberType NoteProperty -name 'DestinationSmtp' -Value $DestinationSmtp
$report | Add-Member -MemberType NoteProperty -name 'ExchangeGUID' -Value $ExchangeGUID
$report | Add-Member -MemberType NoteProperty -name 'LegacyExchangeDN' -Value $LegacyExchangeDN
$report | Add-Member -MemberType NoteProperty -name 'ArchiveGuid' -Value $ArchiveGuid
$report | Add-Member -MemberType NoteProperty -name 'AdditionalX500' -Value $AdditionalX500Array
$ExportFile = "C:\temp\Export.csv"
$report | Export-CSV $ExportFile -NoTypeInformation -Encoding UTF8 -Append
}