New-ExoPSSession there is error after importing the exo module

Arathi Jinde 6 Reputation points
2019-12-05T07:19:35.69+00:00

Hi, after importing the exchange online powershell module , when tried to execute the command New-ExoPSSesssion command there is error please help error details below

Tried same as here with nugetpackage still the same error please help
https://social.msdn.microsoft.com/Forums/en-US/456c0728-ba4e-40ee-b4ff-3ebae0a48a37/error-when-executing-partnercredentialsinstancegeneratebyapplicationcredentials?forum=partnercenterapi

ERROR is : New-ExoPSSession : Could not load file or assembly 'Microsoft.IdentityModel.Clients.ActiveDirectory, Version=2.16.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. At line:1 char:1 + New-ExoPSSession + ~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [New-ExoPSSession], FileNotFoundException + FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.Exchange.Management.ExoPowershellSnapin.NewExo PSSession

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
22,645 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Vasil Michev 111.1K Reputation points MVP
    2019-12-05T08:46:21.413+00:00

    It doesn't work on PowerShell Core, just good old Windows PowerShell for now. If you need to access it from a non-windows machine, there's a version available in Azure Cloud Shell.

    1 person found this answer helpful.
    0 comments No comments

  2. Arathi Jinde 6 Reputation points
    2019-12-05T08:56:05.11+00:00

    I am trying to execute the command let in C# by creating a runspace pool and executing

    here command New-ExoPSSession fails with error

    using (PowerShell powershell = PowerShell.Create())
            {
                powershell.RunspacePool = ExchangeOnlineRunspacePool.Instance.RunspacePool;
    
                powershell.Commands.AddCommand(command);
    
                try
                {
                    if (powershell.RunspacePool.RunspacePoolStateInfo.State == RunspacePoolState.Opened)
                    {
                        results = powershell.Invoke();
    

    }

    Command command = new Command("Import-Module");
    command.Parameters.Add(new CommandParameter("name",moduleFullPath));
    //ExchangeManagement.ExecuteCommand(null, ExchangeVersion.Exchange_Online, command, null, true);
    ExecuteCommand(command);

    ======================================================
    command = new Command("New-ExoPSSession");
    command.Parameters.Add(new CommandParameter("ConnectionUri", ConnectionUri));
    command.Parameters.Add(new CommandParameter("AzureADAuthorizationEndpointUri", AzureADAuthorizationEndpointUri));
    command.Parameters.Add(new CommandParameter("Credential", PowershellCommonUtilities.GetPSCredential(connectInfo.UserName, connectInfo.Password)));
    ExecuteCommand(command);

    }

    1 person found this answer helpful.
    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.