r/PowerShell • • Dec 31 '19

Helpdesk/Remote Support Powershell Script - Expedite frequent & repetitive helpdesk tasks

https://github.com/Justin-Lund/PS-Remote-Support
122 Upvotes

31 comments sorted by

View all comments

Show parent comments

0

u/[deleted] Jan 01 '20

[deleted]

5

u/admiralspark Jan 01 '20

Does the shortcut run set-executionpolicy bypass? It sort of depends on the context and session, it might be good or it might set it for your session or even worse, all sessions.

What I would do instead is look into setting up code signing. I just run a single command and it signs my script and embeds the signature, and since I used our internal CA to do it my code is trusted on all of our machines. The only catch is that you have to remember to re-sign it if you change any of the code but that's easily solved by having your ci/cd do the signing and only allow code to run that made it successfully through ci/cd.

If you're not that far along your journey, I'd look at code signing by hand or use PSSessions and set it to bypass only within that session.

1

u/Kaeny Jan 01 '20

Yea. So my shortcut target starts like powershell.exe set-executionpolicy bypass -file “filename”

Well, the issue is we manage multiple tenants and so we dont have a managed CA in every site, and the simple scripts i use dont seem to warrant having it signed.

Especially when using my scripts on other people’s computers on their network.

The scripts are simple scripts like swapping hostnames in the mapped drives. I just either go around and run it on the required devices when needed, or im thinking of pushing it thru gpo; thinking self signed cert is the way to go for scalability and for the future.

But also it doesnt feel worth the trouble unless it is a bigger script. The shortcut thing is a workaround

5

u/admiralspark Jan 01 '20

Mmm, your process will definitely clear on reboot. If you're an MSP, have you guys considered doing a one-way trust of your domains? That way you can manage their equipment without exposing yourself, and you could run it all remotely without having to be on their demain/their conputers in the first place to do so.

I think you're 80% fine, just don't set exec policy to bypass via GPO or something :)

2

u/Kaeny Jan 01 '20

Thank you very much for your help. I will look into one-way trust for the future.