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 dont know exactly when it will be ready.