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

AWSPowerShell.NetCore 3.3.428.0 | New-PSSession fails, WSMan client library not found

Open CloudViking86 opened this issue 7 years ago • 2 comments

Hello,

Importing module ./Modules/AWSPowerShell.NetCore/3.3.428.0/AWSPowerShell.NetCore.psd1 [Error] - This parameter set requires WSMan, and no supported WSMan client library was found. WSMan is either not installed or unavailable for this system.

Trying to invoke "New-PSSession" and receive the following error above.

Expected output would be "Connection succeeded" or possibly warnings about requiring the "-UseSSL" parameter since the "machine" trying to execute the cmdlet isn't domained joined or using Kerberos.

Works locally with PowerShell Core 6.1.1 which reports "WSManStackVersion 3.0".

Thanks for your assistance / Karl

CloudViking86 avatar Dec 19 '18 08:12 CloudViking86

Hi CloudViking86, The error you're seeing is expected as (as far as I'm aware) the WSMan client is not available on Linux.

In my opinion, your best choice to perform remote execution of PowerShell against a Windows (/or Linux) system from the PowerShell Lambda implementation is to leverage AWS Systems Manager Run Command. This provides a secure execution process where the target only requires outbound TCP/443 access. This removes the need for Lambda to be VPC connected, improves cold-start times as you don't need an ENI attachment, and you don't need to open ports on your target system as the Systems Manager Agent creates an outbound connection to the messaging service.

Other benefits are that you don't need to store/retrieve "Windows" credentials, and as it's an AWS API call you can make it natively from Lambda (assuming you have the correct IAM Policy). AWS Systems Manager also integrates with AWS CloudTrail so all API requests can be logged within your AWS account.

-Andrew

austoonz avatar Jan 31 '19 04:01 austoonz

Does this mean that we cannot run "Connect-ExchangeOnline -Credential $creds" because it requires WSMAN? I'm running into the same issue describe above. Powershell Script is working fine locally, running on MacOS but when I deploy it in AWS it keeps complaining about:

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

Any thoughts on how I can get passed this dependency and be able to connect to Exchange PowerShell from Lambda function

andybirenzi avatar Mar 08 '21 20:03 andybirenzi