O365 PowerShell "You Do Not Have Permissions"
Posted on 2016-09-07
I'm having issues running a Command in PowerShell for O365. I have done this before with the same account but I have no idea what changed or how. When connecting to Power Shell I run:
$UserCredential = Get-Credential
(This will ask me for my O365 login which I input as usual)
Connect-MsolService -Credential $UserCredential
We have a hybrid environment with multiple domain and when I try to change a users domain I run: Set-MsolUserPrincipalName -UserPrincipalName firstname.lastname@example.org -NewUserPrincipalName email@example.com
then I get:
Set-MsolUserPrincipalName : Access Denied. You do not have permissions to call this cmdlet.
At line:1 char:1
+ Set-MsolUserPrincipalName -UserPrincipalName firstname.lastname@example.org ...
+ CategoryInfo : OperationStopped: (:) [Set-MsolUserPrincipalName], MicrosoftOnlineException
+ FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.UserNotFoundException,Microsoft.Online.Administration.Automation.SetUserPrincipalName
Again, I have used this account before and have performed this action without any issues before. Not sure what changed or how to fix. Any help will be appreciated.