Powershell is not working Properly

Hi Guys,

When i try to use power shell integrate with Microsoft am getting the following error(Please see the attached screenprint) when i use this command ‘Connect-MsolService’ none of the Microsoft commands are not working

Please advice on this.i dono whether am making mistake in selecting the Type Argument.

1 Like


I faced the same issue in a machine and I would assume, that the error could perhaps be either:

  • Wrong path or
  • Execution policy on your machine

Most likely the last scenario. Try to see this post for more information (execute a PowerShell command before the one you need to allow the execution of your script)


1 Like

Hello @mmc
Thanks for your valuable reply.

i tried with all the following below commands in Invoke Powershell Activty but none of the things gave me a luck
1.set-executionpolicy unrestricted
2. Set-ExecutionPolicy RemoteSigned

Whether i need to select any particular ‘TypeArgument’ for Invoke Powershell Activty ?

Please advice on this i attached the screen print of the error.Security%20UI%20Path

1 Like

It seems like you are not a local administrator in the machine.
Try to construct this PowerShell activity instead (taken from a XAML file):

<ui:InvokePowerShell x:TypeArguments=“sma:PSObject” ContinueOnError="{x:Null}" CommandText=“Set-ExecutionPolicy” DisplayName=“Invoke Power Shell - Set policy” sap2010:WorkflowViewState.IdRef=“InvokePowerShell`1_2”>

       <InArgument x:TypeArguments="x:String" x:Key="-Scope">Process</InArgument>
       <InArgument x:TypeArguments="x:String" x:Key="-ExecutionPolicy">Bypass</InArgument>


Hello @mmc

i tried to copy and paste that workflow(Activity) in my UiPath Studio but it is not getting.

Can you please tell me how to do this as a Activity?

Sorry, am new to UiPath please guide me.

Thanks for your help.

Hi Arun

First invoke the PowerShell command:

Then for the input parameters set them as the following:

Please see if that helps your PowerShell execution.



Thanks for your quick replies it’s really help me lot.

I tried with this workflow as you guided but no result am getting an errror.

Type Argument as ‘System.Management.Automation.PSSecurityException’

Can you please try to help me on this?


Execution%20error lease find the attached image.

Hi Arun

It seems like the parameters are incorrect.
I have attached an XAML file with the PowerShell Invoke I am using. Please try this:

PowerShell_Invoke_Test.xaml (4.8 KB)


Hello @mmc

Thank you once again its perfect.

My achievement is to connect the Office 365 using in Power shell in UiPath . Using the below commands

1.Install-Module -Name AzureAD



4.Import-Module MsOnline

When i try to use the below commands am getting an error present as present in the attached screen print

Also,please find my workflow for your reference PowerShell_Invoke_Test.xaml (5.0 KB)

Hi Arun
I believe you are facing the same problem as the first with the parameters. You need to put the:

-Name AzureAD

parameter in the Input Parameters as well. And not with the command:



Furthermore. Maybe the “Install-Module” needs Administrator Rights to run? That issue I unfortunately cannot help you with as I do not know how.


Hello @mmc

I tried with this parameters now am not getting any error but i added scope as current user. is it correct?

Please find the attached screen print.


But when i try with the below commands



4.Import-Module MsOnline

it’s throwing an error

Hi Arun
Here I cannot helt you, as I do not know these commands and the usage, but I think you cannot execute the command because it is not available for you (e.g. that the AzureAD module is not installed - try to execute the commands directly in your PowerShell prompt).
Best of luck - maybe others have input to your request.

Thanks @mmc for your valuable answers ans great to contact with you.

Any luck here @arunshiva? I’m having the same issue currently and have tried all the above without success

The stranger thing is, I can run the “connect-msolservice” command without issue in an elevated Powershell session and it’ll connect just fine, but the moment I run that same command in UIPath, it says it cannot be found - even if I manually type it in the prompt that UI Path opens,it fails.

Powershell is currently set to always start as Admin… also tried running UIPath in admin too to see if that would get it to move the needle but to no success. The module is definitely installed as otherwise it wouldn’t work each time I open powershell manually and enter it.

Would appreciate any tips, troubleshooting methods, or similar that could help here.


No there is some problem with executing a commands in UiPath and also i could not find a demo class or a session video for Power Shell Activity also in UiPath Academy.

@ovi i think she is the right person to guide us regarding this blog.

Going to tag @loginerror as well since he’s also been quite helpful in my experience with assisting in resolving issues. Are you able to direct this to anyone who can assist?

The behavior is extremely strange considering it only happens when UI Path launches the Powershell application thus it has to be the fault of however UI Path runs the powershell application/scripts. Manually running Powershell and entering this command doesn’t have a single issue, nor does saving it as a script and running it - the only way it fails is through Studio.

I’ll put in a ticket as well through work here since we have access to the support team via a license/certified UI Path partnership.

Hi @Jon4than

Thank you for also logging a ticket with our support.

Maybe I didn’t get the full picture, but could you clarify:

  • does it also fail if you run the PowerShell as an application from within UiPath and surface automate it with your commands (in contrary to using the Invoke Power Shell Activity)?

The fact that an activity cannot execute a command that works manually is definitely a sign of a buggy behaviour and we will investigate.

1 Like

Does it also fail if you run the PowerShell as an application from within UiPath and surface automate it with your commands (in contrary to using the Invoke Power Shell Activity)?

It fails every time when you run it from UI Path using any of the following:

  1. Invoke PowerShell (IsScript checked)
  2. Start Process (Using: C:\Windows\System32\WindowsPowershell\v1.0\Powershell.exe + with an attribute of “Run As Administrator” checked)
  3. Start Application (Powershell) and then manually entering the command in once it’s opened from UI Path

The only successful way we can make the process work as intended is loading Administrator Powershell from the start menu and typing it in. All the other approaches throw the same error.


Hi everyone,
I`m afraid that there is a limitation here.
The problem lies with the fact the the UiPath Executor runs with normal rights.
The script that you are attempting to run requires elevation.

For now, unless you hack the UiPath Excecutor process to start up with elevated rights (not something we encourage or support… yet) the invoke powershell activity will not be able to run scripts which require elevation - including of course, ones that try to elevate the executor itself.

Now, were you to run these scripts in attended mode, you could create the scripts in such a way that the you get a prompt requiring elevation of the process - the famous Windows “Requires Elevation” window.

However, in unattended mode, the robot will not be able to interact with the window as there is no admin there to accept its elevation. I hope this makes sense.

Still, so as to not end in a negative tone, the Developers covering this part of the code (really smart guys) have already begun developing a feature that will allow just this, as there are quite a few situations where elevating the executor is mighty useful. This feature is coming, but Im afraid I dont know exactly when it will be ready.