We can use Remove-PublicFolderDatabase -Identity “<server>\<storage group>\<public folder database>” to remove public folders from the server but we have to remove all replicas beforehand.
Below command will provide details of replica
Get-PublicFolderStatistics –Server SERVERNAME
To remove replica below command from script folder
.\moveallreplicas.ps1 –server “old server” –newserver “newservername”
If above command didn’t work and the folder data is not important we can use below command
Get-PublicFolderStatistics –Server SERVERNAME | Remove-PublicFolder
If all fails go ADSIEDIT and remove the Database manually.
How to gracefully remove database
To use the Exchange Management Shell to remove a public folder database
- Depending on your scenario, perform the steps listed in “Removing a Public Folder Database From a Mailbox Server” or ” Removing the Last Public Folder Database From an Organization” in the topic Removing Public Folder Databases.
- Run the following command:
- Remove-PublicFolderDatabase -Identity “<server>\<storage group>\<public folder database>”
|If you have not moved public folder replicas to another server, or if you have not removed all of the public folders in the public folder database, you will receive an error stating that the public folder database cannot be removed because it contains public folder replicas. For detailed instructions about how to remove public folders, see Removing Public Folder Databases.|
- A message appears asking you to confirm that you want to perform this action. Enter Y.
- A warning appears, indicating that the database was removed and reminding you to manually remove the database file. The default location for these files is C:\Program Files\Microsoft\ExchangeServer\Mailbox\<storage group name>\<public folder database name>.