Solved

O365 PowerShell "You Do Not Have Permissions"

Posted on 2016-09-07
3
318 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
3 Comments
 
LVL 40

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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Find out what the Office 365 disclaimer function is, why you would use it and its limited ability to create Office 365 signatures.
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…

777 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