Solved

O365 PowerShell "You Do Not Have Permissions"

Posted on 2016-09-07
3
643 Views
Last Modified: 2016-09-09
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 username@domain.onmicrosoft.com  -NewUserPrincipalName username@ourdomain.org

then I get:

Set-MsolUserPrincipalName : Access Denied. You do not have permissions to call this cmdlet.
At line:1 char:1
+ Set-MsolUserPrincipalName -UserPrincipalName asdf@cplc.onmicrosoft.co ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + 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.
Thanks
0
Comment
Question by:menendeza
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 41

Assisted Solution

by:Vasil Michev (MVP)
Vasil Michev (MVP) earned 100 total points
ID: 41788195
The error messages can sometimes be misleading. You will get the exact same error if the user is not found, for example:

[17:31:00][Login script]# Set-MsolUserPrincipalName -UserPrincipalName sdfdsfds@domain.com -NewUserPrincipalName user@domain.com
Set-MsolUserPrincipalName : Access Denied. You do not have permissions to call this cmdlet.
At line:1 char:1

Open in new window


So, double-check the user, his UPN might be a custom domain, not the default onmicrosoft.com one. And of course, double-check the credentials.
0
 
LVL 16

Accepted Solution

by:
FOX earned 400 total points
ID: 41788223
Use steps in this link to connect to your EXCHANGE ONLINE SESSION. (IT HAS COMMANDS FOR SHAREPOINT AND ANOTHER SESSION AS WELL)
You probably didn't set your execution policy.

ref link: https://technet.microsoft.com/en-us/library/dn568015.aspx
0
 

Author Comment

by:menendeza
ID: 41791286
Thank you Foxluv
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows 10 came with  a lot of built in applications, Some organisations leave them there, some will control them using GPO's. This Article is useful for those who do not want to have any applications in their image (example:me).
In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

731 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question