unable to connect powershell

Glenn Maxwell 13,261 Reputation points
2023-01-07T15:49:46.967+00:00

Hi All
i am unable to connect to Security & Compliance PowerShell. i am getting below error. i am able to connect to exchange online powershell module. i have global admin, ediscovery administrator, organization management, compliance administrator access. i dont have below registry entry on my machine
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WinRM\Client

Connect-IPPSSession -UserPrincipalName ******@contoso.com  

  
WARNING: Your connection has been redirected to the following URI: "https://nam11b.ps.compliance.protection.outlook.com/Powershell-LiveId?BasicAuthToOAuthConversion=true;PSVersion=5.1.19041.2364 "  
Processing data for a remote command failed with the following error message: The request for the Windows Remote Shell with ShellId ACE897HT-8796-8157-9/y76-C87E90823EE6 failed because the shell was not   
found on the server. Possible causes are: the specified ShellId is incorrect or the shell no longer exists on the server. Provide the correct ShellId or create a new shell and retry the operation. For   
more information, see the about_Remote_Troubleshooting Help topic.  
At C:\Program Files\WindowsPowerShell\Modules\ExchangeOnlineManagement\3.0.0\netFramework\ExchangeOnlineManagement.psm1:726 char:21  
+                     throw $_.Exception.InnerException;  
+                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
    + CategoryInfo          : ResourceUnavailable: (:) [], ParentContainsErrorRecordException  
    + FullyQualifiedErrorId : System.Management.Automation.Remoting.PSRemotingDataStructureException  
Exchange Online
Exchange Online
A cloud-based service included in Microsoft 365, delivering scalable messaging and collaboration features with simplified management and automatic updates.
{count} votes

Answer accepted by question author
  1. Limitless Technology 45,186 Reputation points
    2023-01-10T09:03:53.787+00:00

    Hi. Thank you for your question and reaching out. I’d be more than happy to help you with your query.

    According to this article https://learn.microsoft.com/en-us/powershell/exchange/connect-to-scc-powershell?view=exchange-ps

    The requirements for installing and using the module are described in Install and maintain the Exchange Online PowerShell module.

    After you connect, the cmdlets and parameters that you have or don't have access to is controlled by role-based access control (RBAC).

    For more information about it, please see the link that I have provided above.

    If the reply was helpful, please don’t forget to upvote or accept as answer, thank you.

    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Amit Singh 5,321 Reputation points
    2023-01-09T09:35:20.137+00:00

    I think you may have to create a
    secure credential object SecureCreds credential = new PSCredential(username, password);
    And then use basic authentication.

    0 comments No comments

  2. Kai Yao 37,781 Reputation points Moderator
    2023-01-09T06:47:07.097+00:00

    Hi @Glenn Maxwell

    Here is a link about this issue: How do you know you've connected successfully?
    Please refer to this part:

    You might fail to connect if your client IP address changes during the connection request. This can happen if your organization uses a source network address translation (SNAT) pool that contains multiple IP addresses. The connection error looks like this:

    The request for the Windows Remote Shell with ShellId <ID> failed because the shell was not found on the server. Possible causes are: the specified ShellId is incorrect or the shell no longer exists on the server. Provide the correct ShellId or create a new shell and retry the operation.

    To fix the issue, use an SNAT pool that contains a single IP address, or force the use of a specific IP address for connections to the Security & Compliance PowerShell endpoint.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  3. JimmySalian-2011 44,986 Reputation points
    2023-01-07T17:23:31.947+00:00

    Hi,

    Did you open PS with admin elevated access? Also try to flush DNS on the system, seems like some kind of network connectivity issue.

    Try the listed steps here invalidshellid-error-in-rps.md

    Hope this helps.
    JS

    ==
    Please Accept the answer if the information helped you. This will help us and others in the community as well.

    0 comments No comments

Your answer

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