aws-lambda-dotnet icon indicating copy to clipboard operation
aws-lambda-dotnet copied to clipboard

Remote connect new-pssession fails - Unable to load shared library 'libpsrpclient' or one of its dependencies.

Open softwaresamuraisarathy opened this issue 8 years ago • 6 comments

Followed the steps given in the URL and deployed below Powershell Core script as a Lambda Function.

--------------------------------------- Script ---------------------------------

#Requires -Modules @{ModuleName='AWSPowerShell.NetCore';ModuleVersion='3.3.335.0'}

$pw = convertto-securestring -AsPlainText -Force -String "Password" $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist "UserID",$pw

$s = new-pssession -computername "AWSECS2DNS" -credential $cred

Invoke-Command -Session $s -ScriptBlock {Get-Service}


When trigger the Lambda function, It fails. This Powershell script tries to remote connect a Windows EC2 Instance and run Commandlet "Get-Service". It fails at the Commandlet "new-pssession". Same script runs fine in Windows Computer powershell.

--------------------------------------- Error -----------------------------------------------

{ "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 Amazon.Lambda.PowerShellHost.PowerShellFunctionHost.ExecuteFunction(Stream inputStream, ILambdaContext context)", "at lambda_method(Closure , Stream , Stream , LambdaContextInternal )" ] }

softwaresamuraisarathy avatar Oct 04 '18 21:10 softwaresamuraisarathy

I have noticed the same problem when attempting to deploy a powershell lambda function. Executes locally correctly, but fails in lambda with the above error.

knabb avatar Oct 29 '18 16:10 knabb

Same here, I notice the Get-PSSesssionOption is also missing. I'm thinking the Publish-AWSPowershellLambda is not capturing all the DLLs for PSCore into the zip.

JustinGrote avatar Dec 27 '18 23:12 JustinGrote

This may also be relevant, they changed libpsrpclient to psrp, maybe something in the code didn't get the memo: https://github.com/PowerShell/PowerShell/pull/3477

JustinGrote avatar Dec 27 '18 23:12 JustinGrote

Hi @softwaresamuraisarathy,

Good afternoon.

I was going through backlog and came across this 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

ashishdhingra avatar Oct 16 '20 19:10 ashishdhingra

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.

github-actions[bot] avatar Oct 31 '20 00:10 github-actions[bot]

The solutions suggested in the AWS forums doesn't work for me. I'm on MacOS and can't seem to find following dependecies : 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.

andybirenzi avatar Mar 08 '21 21:03 andybirenzi