I finally do not need to manipulate the strings passed into Invoke PowerShell activity rather use the method with parameters, a much elegant way to pass UiPath variables/arguments as you suggested.
Thank you. I am going to refer to this tutorial a lot in the forum answers!
Getting below erro, when I tried to invike power shell script
Invoke Power Shell: A command that prompts the user failed because the host program or the command type does not support user interaction. The host was attempting to request confirmation with the following message:
When you poll the command Get-Process in PowerShell, it is creating an object and not a string. So the casting fails as your output variable is set to string.
From documentation
By default, this cmdlet returns a process object that has detailed information about the process and supports methods that let you start and stop the process.
I assumed that since echo $output worked in a PS window it was simply trapping stdout, which is really what I want to do.
Is there a way to run a powershell command (from invoke powershell) and have the powershell stdout captured into a UIPath powershellvariable? I understand how to use the invoke powershell activity parameters, but I am baffled by the invoke powershell powershellvariables.
Hello Huston,
thank you very much.
If I have a script that is printing size of files in PS, how can I get this text as a String? I tried to get it from ‘Output’, but I get a generic object and not sure how to get the output text from it. Do you have any idea?
You may try to save the output of your PowerShell script in a text file and then read the text file (Read Text File activity) as a string and manipulate its data at your discretion. PowershellExample.zip (25.8 KB)
Or, as you did, retrieve it from strPowershellStdout.
Instead, my command is not getting executed and I get null in the Value var of the PowerShellVariables.
If I use the “Output” value of the “Invoke Power Shell” activity, with the default PSObject type, I get null in the variable, but the command gets executed, though.
The only way for my to retrieve a value is changing the Output type to a generic Object. Then, I get a collection of objects, with only one object, and while debugging I can see the contents as text. But then, I don’t know how to treat it to get the value of the property I’m looking for. And I don’t want to, also, because it doesn’t make sense to do a lot of processing on a String to get that value.
This is supposed to be a “step-by-step” guide about the Power Shell activity. But there’s no mention about what the “powershellvariables” are for. There’s on user who asked for clarification about that TWO YEARS ago. Me myself asked for this 3 months ago. No reply whatsoever.
Can anyone for god’s sake clarify what is this for and how to use it? Can the documentation about this ( PowerShell and UiPath - “Invoke PowerShell” Tutorial | UiPath) be written at least in a way that ALL the properties and parameters there are explained?? This is madness!
i have a linux machine which i am getting connected with command prompt for the time being… i am facing two issues using command line and trying to use SHELL for a quality output
these would be a similar commands i am passing in CMD