rannn505 / child-shell

Node.js bindings 🔗 for shell
http://rannn505.github.io/child-shell/
MIT License
301 stars 71 forks source link

Invoke Failed with message "PS_CMD_FAIL_ERROR" #111

Open RohitYadav-msft opened 4 years ago

RohitYadav-msft commented 4 years ago

Requirement : Implement an Azure DevOps pipeline task, in which we need to invoke powershell script from typescript. Here we are using invoke-expression command of power shell in addCommand( ) method of node-powershell library.

Using node-powershell library in TypeScript to implement an azure pipeline task, I am invoking an power shell script from TypeScript file using addCommand( ) method of node-powershell in which I am using invoke-expression command of power shell to invoke an power shell script. But the behaviour of the node-powershell is not consistent sometimes it executes the script successfully and sometimes it just getting failed with message "PS_CMD_FAIL_ERROR" , there is no additional logs/stack trace to find out the root cause of this issue.

Expectation : First why it's showing inconsistent behaviour, second if there is any issue with syntax or issue with the compute node, it should provide detailed logs/stack trace to fix the issue.

There may be an bug in addCommand( ) due to which it is failing while running invoke-expression command of powershell and getting failed while invoking an power shell script.

image