A couple weeks ago I came across a client issue enabling CloudPBX for Skype for Business Online users. The correct Set-CsUser command that would normally enable users, was bleeding red errors in PowerShell. The command is pretty straight forward and was successful the day before.
An example command:
set-csuser -identity email@example.com -EnterpriseVoiceEnabled $True -HostedVoiceMail $True -OnPremLineURI tel:+12345678901
Instead of enabling the specific user for CloudPBX, PowerShell returned an “Object reference not set to an instance of an object” error. Stripping down the cmdlet, it was determined that the error occurs when attempting to set the EnterpriseVoiceEnabled parameter on Set-CsUser to $True.
After hitting up the MVP Community, I have found this is occurring globally and randomly within Office365.
Although I can’t explain what triggers the issue, I have come up with the following workaround that can help others that are experiencing the (hopefully temporary) issue that could be preventing CloudPBX deployments.
The fix is to set the HostedVoiceMail parameter on Set-CSUser to $True alone without any other parameters, after doing so wait ~10 seconds and run your original Set-CsUser command setting the Enterprise Voice parameters and all is successful. If HostedVoiceMail is already $True and seeing the issue with EnterpriseVoiceEnabled, toggle HostedVoiceMail to $False and back to $true and should be good to go.