aws / aws-tools-for-powershell

The AWS Tools for PowerShell lets developers and administrators manage their AWS services from the PowerShell scripting environment.
Apache License 2.0
235 stars 78 forks source link

Connecting to ExchangeOnline through Lambda PowerShell fails with: "Unable to load shared library 'libpsrpclient' or one of its dependencies... #203

Closed andybirenzi closed 3 years ago

andybirenzi commented 3 years ago

Description

I'm have following script in my pwsh lambda function:

Reproduction Steps

$creds = New-Object System.Management.Automation.PSCredential -ArgumentList $username, $secureStringPwd

Connect to Exchange Online

Connect-ExchangeOnline -Credential $creds

Logs

"errorType": "PSRemotingTransportException", "errorMessage": "This parameter set requires WSMan, and no supported WSMan client library was found. WSMan is either not installed or unavailable for this system.", "stackTrace": [ "at Amazon.Lambda.PowerShellHost.PowerShellFunctionHost.ExecuteFunction(Stream inputStream, ILambdaContext context)", "at lambda_method(Closure , Stream , Stream , LambdaContextInternal )" ], "cause": { "errorType": "DllNotFoundException", "errorMessage": "Unable to load shared library 'libpsrpclient' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibpsrpclient: cannot open shared object file: No such file or directory", "stackTrace": [ "at System.Management.Automation.Remoting.Client.WSManNativeApi.WSManInitialize(Int32 flags, IntPtr& wsManAPIHandle)", "at System.Management.Automation.Remoting.Client.WSManClientSessionTransportManager.WSManAPIDataCommon..ctor()" ] }

Environment

Resolution

I just need PowerShell to connect to ExchangeOnline through ModenAuth


This is a :bug: bug-report

ashishdhingra commented 3 years ago

Hi @andybirenzi,

Looks like there was a similar issue https://github.com/aws/aws-lambda-dotnet/issues/332 opened long time back. As suggested in that issue, please refer the forum article https://forums.aws.amazon.com/thread.jspa?messageID=918094 for possible solution. Kindly note that Lambda works on minimal RHEL image. Let me know if it works for you.

Thanks, Ashish

andybirenzi commented 3 years ago

The suggestion solution didn't work for me, I'm not able to find missing dependencies. I'm on MacOS.

The missing deps are: libcrypto.so.1.0.0 libssl.so.1.0.0

I copied them from /opt/microsoft/powershell/6/ to ~/.nuget/packages/microsoft.powershell.native/6.1.0/runtimes/linux-x64/native. Republished and everything worked.

Please suggest if you get it working on Mac

ashishdhingra commented 3 years ago

The suggestion solution didn't work for me, I'm not able to find missing dependencies. I'm on MacOS.

The missing deps are: libcrypto.so.1.0.0 libssl.so.1.0.0

I copied them from /opt/microsoft/powershell/6/ to ~/.nuget/packages/microsoft.powershell.native/6.1.0/runtimes/linux-x64/native. Republished and everything worked.

Please suggest if you get it working on Mac

@andybirenzi Looks like these dependencies are related to Open SSL. Article https://gist.github.com/aklap/e885721ef15c8668ed0a1dd64d2ea1a7 might be helpful. I do see this as a PowerShell specific issue also documented on https://github.com/PowerShell/PowerShell/issues/5561.

github-actions[bot] commented 3 years ago

This issue has not recieved a response in 2 weeks. If you want to keep this issue open, please just leave a comment below and auto-close will be canceled.