Unable to get status of EC2 Instance using a powershell script via Jenkins

Hello,
We are trying to get the status of the EC2 instances (Windows Server) that are hosted in AWS using a powershell script. We are invoking the script via Jenkins. We are getting the below error.
System.Management.Automation.CommandNotFoundException: The term ‘Get-EC2InstanceStatus’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again
When we are triggering the command from the winslave machine we are getting proper response.
Could you please let us know what might be the probable cause.

You’re missing the AWS Tools for Powershell, per the docs for Get-EC2InstanceStatus. You’ll need to install the Powershell package that provides that cmdlet.

See

and

Hi @MarkEWaite ,
Thanks for the reply. Please note we have installed the AWS Powershell and AWS Powershell.NetCore for windows powershell in our winslave.But still we are getting the error while running the script from Jenkins which we are not seeing if we directly invoke the script from winslave.
Is there some missing plugin from jenkins?

No, the problem is that the PATH on that Jenkins agent does not include the directory that provides that Powershell cmdlet.

Hi @MarkEWaite ,

We have AWSPowershell and AWSPowershell.Netcore module installed in the server and under the path
C:\Program Files\WindowsPowerShell\Modules
and C:\Windows\System32\WindowsPowerShell\v1.0\Modules
and both the above paths are added in the PATH of environment variable. Do you want us to include the full path of the modules to be included in the environment variable path ?