Active Directory: Enable Recycle Bin throws an error (PowerShell)
In Active Directory, you have the ability to enable the Recycle bin option, not only from the Active Directory Admin Center but also from PowerShell.
Let's say that you have just setup a new domain or you have an existing one and when you use PowerShell to enable the Recycle Bin or the Admin Center you are presented with an error:
A referral was returned from the server.
and here is the error from PowerShell:
https://everything-powershell.com/wp-content/uploads/2021/04/image-1.png
The PowerShell command in question used is as follows:
Enable-ADOptionalFeature -Identity 'Recycle Bin Feature' -Scope ForestOrConfigurationSet -Target tlab.local
https://everything-powershell.com/wp-content/uploads/2021/04/image.png
At the end you see I have tlab.local at the end of the command, replace this with your internal domain name.
Solution:
To fix the above error, you need to ensure that your domain naming master and schema master roles are on the same domain controller, to move the role you can run the following command:
Move-ADDirectoryServerOperationMasterRole -Identity "Server02" -OperationMasterRole SchemaMaster
https://everything-powershell.com/wp-content/uploads/2021/04/image-2-1024x540.png
Once the above command has completed, you can run the command below to check if replication has taken place and that the Schema Master role is showing on the server you selected to move it it:
netdom query fsmo
Once replication is complete, you can attempt the first PowerShell command or use the GUI to enable the Recycle Bin option.