Am getting error "New-PSSession : [outlook.office365.com] Connecting to remote server outlook.office365.com failed with the following error message : Access is denied. For more information, see the about_Remote_Troubleshooting Help topic."

Rama Gakii 0 Reputation points
2023-10-04T20:49:55.7366667+00:00

Hello team.

I am trying to force exchange In-place archive for a user by name of ******@M365x59079022.OnMicrosoft.com

using PowerShell by running the code below:

$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session
Start-ManagedFolderAssistant -Identity ******@M365x59079022.OnMicrosoft.com

After executing the powershell, I am able to log in using my Global admin accounts but I get this error below

New-PSSession : [outlook.office365.com] Connecting to remote server outlook.office365.com failed with the following error message : Access is denied. For  more information, see the about_Remote_Troubleshooting Help topic. At line:2 char:12 + $Session = New-PSSession -ConfigurationName Microsoft.Exchange -Conne ... +            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     + CategoryInfo          : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotingTransportException     + FullyQualifiedErrorId : AccessDenied,PSSessionOpenFailed Import-PSSession : Cannot validate argument on parameter 'Session'. The argument is null. Provide a valid value for the argument, and then try running the  command again. At line:3 char:18 + Import-PSSession $Session +                  ~~~~~~~~     + CategoryInfo          : InvalidData: (:) [Import-PSSession], ParameterBindingValidationException     + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.ImportPSSessionCommand

I have checked and confirmed that:

  1. The Global admin credentials are okay
  2. I have not enabled security defaults on the tenant
  3. Under Organization management on Exchange admin,I have assigned roles to my admin account

Find Visual imagery for the code and the error receiveUser's image

Exchange Online
Exchange Online
A Microsoft email and calendaring hosted service.
6,199 questions
Exchange | Exchange Server | Other
Windows for business | Windows Server | User experience | PowerShell
{count} votes

3 answers

Sort by: Most helpful
  1. Andy David - MVP 157.9K Reputation points MVP Volunteer Moderator
    2023-10-04T22:01:26.85+00:00

  2. Rama Gakii 0 Reputation points
    2023-10-18T20:01:00.3766667+00:00

    Hello @Jarvis Sun-MSFT I have even created a new Business Premium Tenant and as you can see visually, below are the screenshots for the licenses assignment and Admin Roles

    User's image

    User's image

    Please hopefully everything is checked well

    Here's still our cmdlet

    User's image

    I have run it as s an administrator in the tenant and I did also run powershell in admin mode

    Please where may I be missing something?


  3. Rama Gakii 0 Reputation points
    2023-10-25T05:07:35.4633333+00:00

    I still need help am getting the same error on a jew tenant

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.