question

ArathiJinde-8885 avatar image
0 Votes"
ArathiJinde-8885 asked ·

New-ExoPSSession there is error after importing the exo module

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

azure-ad-multi-factor-authentication
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

michev avatar image
1 Vote"
michev answered ·

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.

· Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ArathiJinde-8885 avatar image
1 Vote"
ArathiJinde-8885 answered ·

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);

}

· Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.