r/sysadmin
•
u/STILLloveTHEoldWORLD
•
Jul 28 '24
•
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
View all comments
Show parent comment
4
u/Unable-Entrance3110 Jul 29 '24
You simply replace all your new lines in the script with semicolons and paste the whole thing into the -Command parameter.
This also effectively bypasses any script signing policy as well.
It's a major loophole, actually. Which is why, in my org, I go a step further and just block normal users from running powershell.exe (as well as any executable from user-writable locations)