1

AWS Recently announced Lambda Support for PowerShell Core. Reference URL https://aws.amazon.com/blogs/developer/announcing-lambda-support-for-powershell-core/

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 I 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. But fails when run as AWS Lambda function. This happens as AWS Lambda function runs in Linux environment. Please help.

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 )"
  ]
}

1 Answer 1

1

Worked with the AWS support team and got the following response:

"After further testing, Lambda service team has confirmed that New-PSSession is currently not supported in lambda environment. This has to do with the way PS Remoting works on PowerShell core for Linux."

Apparently it's a feature on the roadmap, so we may see it eventually.

Sign up to request clarification or add additional context in comments.

2 Comments

I didn't. It isn't supported, as I mentioned above. I ended up using a non-lambda approach instead.
Any idea if this feature is implemented? I'm in need of doing something similar and wondering if i can achieve with Lambda? I did post a question stackoverflow.com/questions/61072978/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.