Attempting to upgrade the forest mode from 2003 to 2008R2, using the command:
Set-ADForestMode –identity %FOREST% –ForestMode Windows2008R2Forest
This was failing with the error:
Set-ADForestMode : A referral was returned from the server
I found the Active Directory Web Services Service hadn’t started.
After starting this service, the Set-ADForestMode command worked fine.