powershell is required to complete this operation; Original message: 'powershell' is not recognized as an internal or external command,operable program or batch file.HRESULT: [-2147024894]"

Uday Gonuguntla
Giga Guru

i am seeing below error when i try to discover target device. what does it mean and what is the solution to fix this?   

 

 

powershell is required to complete this operation; Original message: 'powershell' is not recognized as an internal or external command,operable program or batch file.HRESULT: [-2147024894]"

5 REPLIES 5

Ashutosh Munot1
Kilo Patron
Kilo Patron

HI,


Things to check:

1) MID Server should have Powershell installed on it.

2) Target machine should support powershell.

3) Which version of powershell is used by this device needs to be checked.

4) Your discovery user is allowed to run powershell.

https://hi.service-now.com/kb_view.do?sysparm_article=KB0784442

 

ALSO LET ME KNOW IF THE MID SERVER IS ON WINDOWS OR LINUX.


Thanks,
Ashutosh

AbhishekGardade
Giga Sage

Hello Uday,

That's the same message you get if you give a bad path to Powershell.  Try fully qualifying the path to powershell on your instance, or adding the path to the powershell command to your PATH environment variable.

You can verify if this is the issue by logging into the server opening a command prompt and typing "powershell"  If you see the same error, it's probably a path issue.

Is the MID server trying to execute powershell commands on the other machine?

Have you logged into the other machine and verified you can execute powershell without a fully qualified path?  Do you need to enable remote powershell commands:

https://www.howtogeek.com/117192/how-to-run-powershell-commands-on-remote-computers/

If you can, I would try logging into the mid server and manually running the powershell commands and/or add some logging so you can tell if it's failing on the mid server or the remote server side.

Try fully qualifying the path to powershell on that machine, or adding the path to the powershell command to your PATH environment variable.

Please mark as Correct Answer and Helpful, if applicable.
Thank You!
Abhishek Gardade

Thank you,
Abhishek Gardade

Sounds like you're missing an environment variable.

Add this to your Path environment variable:

%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\

OR

Change your script to this:

%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\powershell.exe -Command "your command"

Thanks,
Abhishek Gardade
Thank you,
Abhishek Gardade

Any updates on this?

Can you please mark my response as correct and close this thread so that others with the same question in the future can find it quickly.

Thank You!

Abhishek Gardade

Thank you,
Abhishek Gardade