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)