This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

PowerShell SAM Error not recognized as the name of a cmdlet, function, script file, or operable program.

Hi,

I am working on a SAM Template to run the below piece of code. It is using a 3rd party cmdlet. I can run the script from the Orion Server without any issues.

$psw=ConvertTo-SecureString "TEST" -AsPlainText -Force
Connect-Pfa2Array -Endpoint 20.20.10.10 -Username user -Password $psw -IgnoreCertificateError
$Storage = Pfa2Hardware | Select Name, Serial, Status, Type | Where-Object {($_.Type -eq "drive_bay")} | ConvertTo-Html
write-host "\nMessage: $Storage";
write-host "\nStatistic: 0";

When I try to run from the SAM Component Monitor, I get the below error. Any one has faced a similar issue and how it was fixed?

Connect-Pfa2Array : The term 'Connect-Pfa2Array' 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.
At line:2 char:1
+ Connect-Pfa2Array -Endpoint 20.20.10.10 -Username pureapiuser -Passw ...
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Connect-Pfa2Array:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

Pfa2Hardware : The term 'Pfa2Hardware' 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.
At line:3 char:12
+ $Storage = Pfa2Hardware | Select Name, Serial, Status, Type | Where-O ...
+ ~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Pfa2Hardware:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

  • Are you sure you installed the cmdlet to "all users" and not only "current user"?

    Think you should find the cmdlet binaries herre if correct: C:\Program Files\WindowsPowerShell\Modules

  • Hi,

    Added this to my script and the PowerShell script is now working. This should work for any customer working with 3rd party cmdlets in Orion SAM Powershell monitor. Hope this helps.

     cd "C:\Program Files\Pure Storage\PowerShell\Modules\PureStoragePowerShellSDK2"

    Import-Module .\PureStoragePowerShellSDK2