How to Integrate PowerShell with UiPath- Step by Step guide

Thanks for the tutorial buddy, but the only thing is that a comma is missing between the parameters, so it caused us a while to figure it out :sweat_smile:

So it should be like

[Parameter(Mandatory=$true)] [string]$ServiceState,
[Parameter(Mandatory=$true)] [string]$OutputFilePath

Apologies for that glitch… and thanks for bringing it to notice. I have now added a comment below the Image.
Hope the tutorial helped you overall :slight_smile:

1 Like

Hi @huston8,

This was a great tutorial!

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!

1 Like

Hello @jeevith

Thank you very much for the acknowledgement, this made my day. It was a required for our use case couple of years back and so had to do some R&D. :slightly_smiling_face:

I am glad this is still useful till date.

(Just for info, I had also added another tutorial to run Powershell with admin privileges…Just in case anyone needs it)

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:

Please help.TeamsReports1.txt (13.1 KB)

attached is the .ps1 script

Let me know how to run this script using UiPath?


Can you tell me why the following does not work?


1 Like

Hi @tsverthoff,

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.

Reference : Get-Process (Microsoft.PowerShell.Management) - PowerShell | Microsoft Learn



I understand that get-process returns a process object, or a collection of process objects, but in a powershell console window, this will work:

ps c:\ $output = get-process winword,excel
ps c:\ echo $output

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.

1 Like

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. (25.8 KB)


THANK YOU VERY MUCH!!! it worked perfectly. :raised_hands: :trophy:

1 Like

Did you solve this? I’m struggling with exactly the same problem, and not getting any answer from the UiPath staff.

I’m invoking one single PowerShell command, “New-Team”.

It outputs an object like this one:

powershell - New-Team not returning the groupID - Stack Overflow

So, in theory, if I call it via:

“$myVar = New-Team”

In PowerShell I could do this:


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!

Hi Team,

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

ssh deva_bss@

can we directly pass these commands in text and then read it? or should we configure anything