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.