Invoke PowerShell Limitation?

Hi All!

I am trying to use the Invoke Power Shell activity but I keep receiving an error message. I have tested my script in PowerShell and it is working without an issue (the script is below), is it due to the proper modules not being installed?

Script: "$name = get-aduser -identity $id | select-object -expandproperty name"

18.4.1+Branch.master.Sha.bc66386dd8e2160b6d35f31d5ce934a5aa4cf4bd

Source: Invoke Power Shell (Throw)

Message: The term ‘$name = get-aduser -identity $id | select-object -expandproperty name’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Exception Type: System.Management.Automation.CommandNotFoundException

An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.Management.Automation.CommandNotFoundException: The term ‘$name = get-aduser -identity $id | select-object -expandproperty name’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

  • at System.Activities.Statements.Throw.Execute(CodeActivityContext context)*
  • at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)*
  • at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)*
  • at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)*

Hey @s3vn

Yes there are some limitation i found this article somewhere may be this can help.

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 I m afraid I don t know exactly when it will be ready.

That is really disappointing. I am trying to maintain Active Directory users using UIPath and figured I would try PowerShell since UIPath does not interface with AD anymore :frowning:

Anyone happen to know of any other options?