Sign up for Office 365
Learn more about Office 365
When trying to connect via Powershell to carry out admin tasks, I get an error "access is denied". I use this script;
$LiveCred = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection
And get this response;
WARNING: Your connection has been redirected to the following URI: "https://pod51014psh.outlook.com/PowerShell-LiveID?PSVersion=2.0 "
[pod51014psh.outlook.com] Connecting to remote server failed with the following error message : Access is denied. For more information, see the about_Remote_Troubleshooting Help topic.
+ CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) , PSRemotingTransportException
+ FullyQualifiedErrorId : PSSessionOpenFailed
Import-PSSession : Cannot validate argument on parameter 'Session'. The argument is null. Supply a non-null argument and try the command again.
At C:\Users\phil\Desktop\Office365Login.ps1:3 char:17
+ Import-PSSession <<<< $Session
+ CategoryInfo : InvalidData: (:) [Import-PSSession], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.ImportPSSessionCommand
I suspect my account has somehow got screwed up; I'm also having troubles with a staged mailbox migration, so deleted and recreated my account (using another administrators account), so I suspect I've lost some required privileges somewhere - it did work, a couple of weeks ago...
Thanks for the feedback.
I've worked out that it's a problem with the UPN on my account; if I change it (using Set-MsolUserPrincipleName via the second admin account), everything works OK, and then fails if I revert it back.
There's definately a problem with how my account is setup in Exchange; I also get some unauthorized response errors when trying to connect Outlook 2010, and also when testing autodiscover with www.testexchangeconnectivity.com
How can I reset everything relating to my account (I'm the account owner) ?
I think if you have two administrator accounts, you can try to use the other exchange account to connect to powershell.
If you want to reset your current administrator account, you can try to remove this user’s exchange license and assign to it again. Warning: This action will lost all the data in this mailbox.
I have had this exact issue as well, started about a week ago.
Changing the UPN fixed it for me too, and bizzarly changing it back broke it again!
What is going on?! Any ideas?
Thanks for your feedback . I'm glad to hear that this issue have been resolved on your side.
If you have any other questions when using Office 365 in the future, please feel free to post them in the forum.
Sometimes, some symptom issue may be caused by different root cause. Therefore, I sincerely suggest post some detailed information about the issue, such as some screen shots of the issue occurred, in a new thread in the forum. After that, our support engineer will follow up and help you fix the issue in the new thread. Thanks for your understanding.
I had this same problem and this thread got me onto the right track to a solution, so thanks Phil. Turns out I had deleted the account a week or so ago and re-created it with the same UPN. This is what was causing the problems. I found the deleted account in the MSOL User recycle bin and once I removed it from there, it all worked as expected.
I wrote a blog post about it if anyone is interested: Access Denied when connecting to Office 365 using Powershell
0 out of 1 people found this post helpful.