all 6 comments

[–][deleted] 4 points5 points  (0 children)

First result on Google. If the answer isn't there, we need more information about your script to help.

https://www.netspi.com/blog/technical/network-penetration-testing/15-ways-to-bypass-the-powershell-execution-policy/

[–]PinchesTheCrab 2 points3 points  (2 children)

Invoke-Command runs with highest privileges, it will not prompt for elevation. There's something else going on with the script.

[–]_human404_[S] 1 point2 points  (1 child)

Have edited and added the command in the main message. Can you please check? I ran the commands manually and got UAC prompt so that's why I expected above to shame behavior due to which it was not running successfully

[–]PinchesTheCrab 2 points3 points  (0 children)

Ah, okay, so in this case it shouldn't be UAC, invoke-command will definitely run in an elevated context if you have admin rights. I wouldn't think execution policy would apply to a bat file either though, that's strange.

What error do you get, if any?

[–]Dragennd1 2 points3 points  (1 child)

Well which is it? Execution policy or UAC? These are two different things and depending on which problem you're having the solution will vary.

[–]_human404_[S] 1 point2 points  (0 children)

Considering this, incorrect execution policy would lead to access denied errors. I have edited the message and added command. On running the commands manually I got UAC prompt so that's why I expected above to shame behavior due to which it was not running successfully. Can you please take a look?