-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPublic_Folder_to_Office365_Group_Migration.ps1
69 lines (44 loc) · 3.89 KB
/
Public_Folder_to_Office365_Group_Migration.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# This script migrates existing Public Folders that are on-premises to a group that exists in Office 365.
# Step 1 is to create a new Office 365 Group (Team) or know/use (the SMTP of) an existing one.
# Get-UnifiedGroup = Get all Office 365 groups.
# TargetGroupMailbox = SMTP address of Office 365 group.
# After creating a new Office 365 Group, must unhide it: Set-UnifiedGroup -Identity "Legal Department" -HiddenFromAddressListsEnabled $false
# For public folders wi/ subfolders, have to run a migration batch individually for each item.
# How to remove migration endpoint: Remove-MigrationEndpoint -Identity CrossForestME01
# Have to add user as owner of public folder to successfully complete a migration batch.
# How to add user as Owner to Public Folder
Add-PublicFolderClientPermission -Identity "\2 - Departments\IS\IS - Systems Calendar\" -User 'domain.com/Domain Users/' -AccessRights Owner
Add-PublicFolderClientPermission -Identity "\2 - Departments\IS\" -User 'domain.com/Domain Users/IS Operations/Users/' -AccessRights Owner
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri URL -Authentication Kerberos
Import-PSSession $Session
# Login using AD creds.
Connect-AzureAD
Connect-MsolService
# Login using AD creds.
$Session2 = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session2
Get-PublicFolder -Identity "\2 - Departments\IS"
Get-PublicFolder -Identity '\2 - Departments\IS' -Recurse | fl Name, Replicas, OriginatingServer
# Step 3-Create the .csv
Get-Mailbox "[email protected]" | Select-Object LegacyExchangeDN
#LegacyExchangeDN
#----------------
#/o=company/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=Alex Testb8c
Get-RemoteMailbox "[email protected]" | Select-Object LegacyExchangeDN
#LegacyExchangeDN
#----------------
#/o=company/ou=External (FYDIBOHF25SPDLT)/cn=Recipients/cn=1b917071994d41738311d008c15e88fb
Get-ExchangeServer emaildb01 | Select-Object -Expand ExchangeLegacyDN
#/o=company/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Configuration/cn=Servers/cn=EMAILDB01
Get-OutlookAnywhere | Format-Table Identity, ExternalHostName
#Identity ExternalHostname
#-------- ----------------
#MAIL01\Rpc (Default Web Site) outlook.domain.com
#EMAIL02\Rpc (Default Web Site) outlook.domain.com
$Source_Credential = Get-Credential
$Source_RemoteMailboxLegacyDN = "/o=company/ou=External (FYDIBOHF25SPDLT)/cn=Recipients/cn=1b917071994d41738311d008c15e88fb"
$Source_RemotePublicFolderServerLegacyDN = "/o=company/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Configuration/cn=Servers/cn=EMAILDB01"
$Source_OutlookAnywhereExternalHostName = "outlook.domain.com"
$PfEndpoint = New-MigrationEndpoint -PublicFolderToUnifiedGroup -Name PFToGroupEndpoint -RPCProxyServer $Source_OutlookAnywhereExternalHostName -Credentials $Source_Credential -SourceMailboxLegacyDN $Source_RemoteMailboxLegacyDN -PublicFolderDatabaseServerLegacyDN $Source_RemotePublicFolderServerLegacyDN -Authentication Basic
New-MigrationBatch -Name is__test -CSVData (Get-Content "C:\Users\user\Desktop\PFtoGroups\test1.csv" -Encoding Byte) -PublicFolderToUnifiedGroup -SourceEndpoint $PfEndpoint.Identity -NotificationEmails "[email protected]"
Start-MigrationBatch is__test