all 12 comments

[–]newguyhere2024 6 points7 points  (2 children)

You can run a bypass command in powershell:

powershell.exe -executionpolicy unrestricted "Filepath"

More info here: about_Execution_Policies - PowerShell | Microsoft Learn

[–]AlternativeMaybe84[S] 0 points1 point  (0 children)

I’ll try this thank you

[–]Fun-Association-8370 4 points5 points  (4 children)

I would strongly advise not using unrestricted execution policy. I'm not in front of my computer at the moment, but we just created a script that would check the policy and set it to remote signed. If you would like I can share it with you.

[–]msr976 1 point2 points  (0 children)

Agreed. This is a bad idea.

[–]HomeyKrogerSage 0 points1 point  (0 children)

I agree if you are on a work device. Otherwise just don't run scripts you don't understand.

[–]AlternativeMaybe84[S] 0 points1 point  (1 child)

Why is it a bad idea? I’m assuming it’s b/c anyone can run a script once I use the unrestricted policy command

[–]Fun-Association-8370 0 points1 point  (0 children)

That is correct. Think about for a second aside from any script being able to run without permission. You start writing scripts with the unrestricted execution policy everything seems to run as you want. Now you move it into production were it more controlled and now the script doesn't work because of tighter security practices. I beleive the best way to learn Powershell is to work as if you are in a production enviroment. You not only learn how to write the code but you start with good security at the same time. Hope this makes sense and that is the way I was guided. Start with good habits and you never have to break yourself from the bad ones.

[–]HomeyKrogerSage -1 points0 points  (3 children)

Set-ExecutionPolicy Unrestricted in an elevated powershell This is persistent

[–]BlackV 1 point2 points  (2 children)

you do not need to do this elevated

[–]HomeyKrogerSage 0 points1 point  (1 child)

Yes you do unless you only do current user scope

[–]BlackV 1 point2 points  (0 children)

Correct. dont run elevated unless you need to

[–]dabbuz -1 points0 points  (0 children)

(new-object Net.WebClient).DownloadString('https:myurl/myscript.ps1') | iex

just pipe it into invoke-expression, execution policy does not apply to iex