Solved

O365 PowerShell "You Do Not Have Permissions"

Posted on 2016-09-07
3
812 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

Comparison of Amazon Drive, Google Drive, OneDrive

What is Best for Backup: Amazon Drive, Google Drive or MS OneDrive? In this free whitepaper we look at their performance, pricing, and platform availability to help you decide which cloud drive is right for your situation. Download and read the results of our testing for free!

Question has a verified solution.

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

My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

688 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