At times in Exchange 2013/2016, if you remove the Public Folder Mailbox which holds the Master hierarchy abruptly, or deleting using Adsiedit.msc, it doesn’t get removed properly.
Where as a result of that master hierarchy goes disappeared. Even if you Create Public Folders it will create as Secondary hierarchy.
So in the first place we need to find the Hidden Master hierarchy.
Running the below command will show which mailbox is the Master hierarchy:
Get-OrganizationConfig | FL Name,Root*
Get the ExchangeGuid Value from RootPubicFolderMailbox
Get-Mailbox –PublicFolder | FL Name,ExchangeGuid
Now you can see which Public Folder holds the Master hierarchy
If you are seeing it, it's good, it's available
But if you are not seeing the ExchangeGuid on this list it means something went wrong and you need to cleanup value in configuration and create new Root PF Mailbox.
Open Adsiedit.msc – Connect to
Expand Configuration –Services – Microsoft Exchange – “Your Exchange Org Name” (Properties)
Cick on Edit and Click on Clear
Choose Ok and Ok again
Now the Master hierarchy goes empty.
First PF Mailbox you create after cleaning "MsExchDefaultPublicFolderMailbox" attribute, will be new Master/Root:
New-Maibox RootPFMailbox –PublicFolder
Which becomes the master hierarchy