-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-AnsweredThe question is answered.The question is answered.Resolution-ExternalThe issue is caused by external component(s).The issue is caused by external component(s).WG-DevEx-SDKhosting PowerShell as a runtime, PowerShell's APIs, PowerShell Standard, or development of moduleshosting PowerShell as a runtime, PowerShell's APIs, PowerShell Standard, or development of modules
Milestone
Description
Steps to reproduce
Same issue as described here:
#5561
except when using Microsoft.PowerShell.SDK (6.2.3) instead of PowerShell CLI
- Create a netcoreapp2.2 console application on Mac OS Mojave
- Add PackageReference to Microsoft.PowerShell.SDK (6.2.3)
- Add code to connect to O365:
var rs = RunspaceFactory.CreateRunspace();
rs.Open();
using (var ps = System.Management.Automation.PowerShell.Create())
{
ps.Runspace = rs;
var initializationScript = $@"
$ErrorActionPreference = 'Stop'
try {{ Set-ExecutionPolicy Unrestricted }} catch {{}} # not supported on non-Windows platforms
$UserCredential = New-Object System.Management.Automation.PSCredential('******', (ConvertTo-SecureString '******' -AsPlainText -Force))
$Option = New-PSSessionOption
$Option.IdleTimeout = [TimeSpan]::FromSeconds(60) # inline setting of this property via New-PSSessionOption is not supported on non-Windows platforms
$Session = New-PSSession -SessionOption $Option -ConfigurationName Microsoft.Exchange -ConnectionUri 'https://outlook.office365.com/powershell-liveid/' -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-Module (Import-PSSession $Session -DisableNameChecking) -Global
";
await ps.AddScript(initializationScript).InvokeAsync();
}
Error:
Unhandled Exception: System.AggregateException: One or more errors occurred.
(This parameter set requires WSMan, and no supported WSMan client library was found. WSMan is either not installed or unavailable for this system.) ---> System.Management.Automation.CmdletInvocationException: This parameter set requires WSMan, and no supported WSMan client library was found. WSMan is either not installed or unavailable for this system. --->
System.Management.Automation.Remoting.PSRemotingTransportException: This parameter set requires WSMan, and no supported WSMan client library was found. WSMan is either not installed or unavailable for this system. ---> System.DllNotFoundException: Unable to load shared library 'libpsrpclient' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(liblibpsrpclient, 1): image not found
at System.Management.Automation.Remoting.Client.WSManNativeApi.WSManInitialize(Int32 flags, IntPtr& wsManAPIHandle)
at System.Management.Automation.Remoting.Client.WSManClientSessionTransportManager.WSManAPIDataCommon..ctor()
If I set DYLD_PRINT_LIBRARIES to 1, I see the following when running from C# right before the error:
dyld: loaded: /Users/jeff/.nuget/packages/microsoft.powershell.native/6.2.0/runtimes/osx/native/libpsrpclient.dylib
dyld: unloaded: /Users/jeff/.nuget/packages/microsoft.powershell.native/6.2.0/runtimes/osx/native/libpsrpclient.dylib
Works:
- Install PowerShell CLI (6.4.0) (on the exact same machine)
- Run
sudo ln -s /opt/local/lib /usr/local/opt/openssl/lib(this doesn't seem to help the C# code any) - Run the exact same script
If I set DYLD_PRINT_LIBARIES to 1 for the CLI, I see the following right before the connection succeeds:
dyld: loaded: /usr/local/microsoft/powershell/6/libpsrpclient.dylib dyld: loaded: /usr/local/microsoft/powershell/6/libmi.dylib dyld: loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib dyld: loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib
so the problem is specific to the SDK...and the ln command fix doesn't seem to work for the SDK.
Expected behavior
Doesn't throw error
Actual behavior
Throws error
Environment data
Mac OS Mojave
Metadata
Metadata
Assignees
Labels
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-AnsweredThe question is answered.The question is answered.Resolution-ExternalThe issue is caused by external component(s).The issue is caused by external component(s).WG-DevEx-SDKhosting PowerShell as a runtime, PowerShell's APIs, PowerShell Standard, or development of moduleshosting PowerShell as a runtime, PowerShell's APIs, PowerShell Standard, or development of modules