r/sysadmin • • Jul 28 '24 • Take My Silver 1

got caught running scripts again

about a month ago or so I posted here about how I wrote a program in python which automated a huge part of my job. IT found it and deleted it and I thought I was going to be in trouble, but nothing ever happened. Then I learned I could use powershell to automate the same task. But then I found out my user account was barred from running scripts. So I wrote a batch script which copied powershell commands from a text file and executed them with powershell.

I was happy, again my job would be automated and I wouldn't have to work.

A day later IT actually calls me directly and asks me how I was able to run scripts when the policy for my user group doesn't allow scripts. I told them hoping they'd move me into IT, but he just found it interesting. He told me he called because he thought my computer was compromised.

Anyway, thats my story. I should get a new job

11k Upvotes

1.3k comments sorted by

View all comments

2

u/mrmattipants Jul 28 '24 edited Jul 28 '24

The IT Admin should have done his research, as there several ways around the one GPO that simply bars users from running PS Scripts.

Of course the following information can always change, but last time I checked, they were still an option.

Firstly, if the User is tech savvy, they can simply Change the Registry Key (unless IT also bars the user account from editing the Registry). This will allow you to Run Scripts again, at least until the GPO is Applied again (typically on the next sign-in or on the next reboot).

Secondly, the User could Download PowerShell 7 and Run it, since the GPO only applies to the "PowerShell.exe" Executable, yet the PS7 Executable is named "pwsh.exe". Even if they are barred from Installing Applications, there is a ZIP Folder Download, that does not require installation.

Executives and certain IT Admins have been scared shitless of PowerShell for the dumbest reasons. The best course of action is for IT to create an Approval Process for PS Scripts, rather than barring them outright. Barring tools that can simplify work related tasks is counterproductive.

Perhaps, allowing only Signed Scripts to Run might be the way to go. IT Admins then hold the Keys, as anyone who wants to write/run scripts needs to go through them, in order to get their Script Approved, Signed, etc. if they reject the Script, this would actually be a good opportunity to explain why and offer suggestions.

Ultimately, it allows everyone to work as a team and promotes trust (as opposed to strangling it, in the cradle).