I did run into the situation that I lost all my public folder permissions which were assigned via groups.
Before the migration started from our MSEX2016 server to Office 365, all the permissions got exported to a XML file, what I think (described on this Microsoft page) happened with the following command:
Get-PublicFolder -Recurse -ResultSize Unlimited | Get-PublicFolderClientPermission | Select-Object Identity,User,AccessRights -ExpandProperty AccessRights | Export-CliXML OnPrem_PFPerms.xml
The output file "OnPrem_PFPerms.xml" has about 5 GB. That sounds a lot to me for permissions only on a about 300 GB PF structure, but maybe is its huge size cause by the complexity of the XML format. 7-Zip compression brings it down to 25 MB, means there is a lot of redundant data in it.
On our MSEX2010 which got migrated to MSEX2016 before is a "Legacy_PFPerms.xml" file with about 500 MB.
What would be the proper PowerShell command to apply all the permissions from the XML file to the public folder structure on the Office 365 / Exchange online?
I guess Import-CliXML would do the job somehow, but I am not that familiar with PowerShell to build the right command.
Finally the following PowerShell script allowed me to apply all the permissions from the XML file to the public folder structure. Thanks to Ivan_Wang who led me to the right direction with his answer.
Is is also possible to split that up in multiple PowerShell sessions to apply the changes faster since it runs pretty slow.
PS session:
foreach($pf in $pfs[0..2000])
...PS session:
foreach($pf in $pfs[2001..4000])
......
Do not run too many sessions at one, otherwise it will interrupt the connection to Exchange Online with the following message:
The request is not serviced on the server. Your request is too frequent.
What're the properties included in the .xml file? If there are Identity and User, AccessRights, you could try:
Based on your command above, it seems to export only the AccessRights object. If so, you may need to export the current ACL list in Exchange Online to a .csv file:
And assign permissions of the public folders to your users again via PowerShell(For existing permission entries, PowerShell will report a warning: An existing permission entry was found for user):
If the source Exchange server is still available you can use the following to export the Public Folder client permissions to a CSV file and import them into Office 365. You'll probably need to edit the source CSV file to edit the usernames to match the Office 365 usernames for each user present in the permissions.
Export Public Folder permissions to CSV:
Get-PublicFolder -Recurse | Get-PublicFolderClientPermission | Select Identity, User, @{ expression={$_.AccessRights}; label='AccessRights' } | Export-Csv C:\Temp\PublicFolderClientPermission.csv
Import Public Folder permissions from CSV:
$Users= Import-CSV C:\Temp\PublicFolderClientPermission.csv foreach ($User in $Users){Get-PublicFolder -Identity $($User.identity) | add-publicfolderclientpermission -AccessRights $User.AccessRights -User $User.User}