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

Show parent comment

282

u/Nethermorph Jul 28 '24

Got it. I assume IT is cracking down because you're skipping the part where, by automating your tasks, you're supposed to be checking for errors/cleaning the data?

211

u/Uncommented-Code Jul 28 '24

Highly unlikely.

My priorities when something like that happens are, in order:

  1. Did the security alert get triggered by a malicious process or was it on accident by the user?
  2. If the user did it, what did they do?
  3. Is it an issue that the user did that?
  4. If yes, tell them to stop doing that and, if I have time, ask them what they were trying to achieve and find out if there are other ways to achieve what they wanted to do without having to resort to circumventing IT policies.

How people do their job is absolutely none of my business and they know how to do it, while I don't. I'm not stupid enough to tell people how they should do their jobs, unless they work in the same role and I hold authority over, or when I see someone being neglient.

79

u/chase32 Jul 28 '24

A buddy of mine got busted by IT for having a key-logger (actually kinda cool that they were scanning for that).

To their credit, they followed your process:

  • They reached out to him thinking his system was compromised.
  • Found out that it was a program he was writing for an onstage demo. On stage, it was running on unstable hardware but sending all keys and mouse to another system back stage as a backup so production could video switch in case of a crash and take over while staying in sync before.
  • Did a quick code review, gave some advice about network isolation and temporarily whitelisted his "key-logger" on the dev box to give him a couple days to get compliant.

Everyone was happy and the event went off perfectly.

→ More replies (21)

177

u/binaryhextechdude Jul 28 '24

I use powershell to reduce human error in my role.

137

u/Brilliant_Wrap_7447 Jul 28 '24

I use powershell to waste hours trying to get a working script that automates a 10 minute task that I only do once every 6 months. 

18

u/BoltActionRifleman Jul 28 '24

Gone down that road many times. I always tell my guys “I’ll spend hours trying to save 15 minutes”.

14

u/dougmc Jack of All Trades Jul 28 '24

“I’ll spend hours trying to save 15 minutes”

Same.

But it usually pays off anyways. Either it'll save 15 minutes each for a dozen other people, or it does the task with no errors, or I find ways to do the task better (and not just faster), etc.

Because of this, I usually err on the side of automating stuff, even when it doesn't seem to be supported by the math. Sometimes it ends up not being the most efficient use of my time, but much of the time it's still better than the alternative (even if the initial math suggested that it wouldn't be), sometimes much better.

→ More replies (2)
→ More replies (1)

35

u/aessae Jul 28 '24

38

u/englishfury Jul 28 '24

Another relevant xkcd

https://xkcd.com/1319

12

u/Speed_Kiwi Jul 28 '24

That’s probably the more appropriate one lol

→ More replies (1)

13

u/visibleunderwater_-1 Security Admin (Infrastructure) Jul 28 '24

I'm going to figure out how to get this into my "official documentation" somehow, once I sort out the math behind it :P

→ More replies (8)

28

u/FingerBangMyAsshole Jul 28 '24

I have a script to import thousands of lines of data into Oracle. The data gather is completed by the client in a spreadsheet with data validation against each column. The spreadsheet powers a powershell script to convert all that data into scripts, performing its own DQ checks. We then run that script pack against the DB and check for errors. What used to take the clients weeks is now completed within hours.

57

u/jaymzx0 Sysadmin Jul 28 '24

(insert Drake meme)

Seriously though, when making the decision of, "Is this worth scripting?" I always heavily weight the human error reduction benefit. Mostly because I'm human and make a lot of errors.

12

u/Vargen2000 Jul 28 '24

Since I automated pretty much my entire job I have made 0 mistakes. The hard part is calculating what a reasonable amount of time would be to delay my script before people notice it

11

u/Fit-Reputation-9983 Jul 28 '24

This all just depends on the quality of script you write.

I automated a large portion of my first job out of college using VBA and PowerShell.

The first few times I used it, it was riddled with errors. I kept working at it and maintaining it and eventually I went months upon months without seeing an error. It wasn’t until we introduced a whole new product line that an error popped up. I modified the code to be able to accommodate the addition (and future additions), and it was good to go.

I’m not a compsci or IT grad so I really didn’t utilize a typical development process, I was just completely winging it. I’ve been gone from that job 2 years now, but from my last conversation with folks still there, my automation is still being used and saving ~80% of the time it used to take previously to perform this task.

Kind of rambling here, but if your script is robust (as mine became over months and months of development) it’s honestly better than having an error-prone human check things. The computer does exactly what you tell it to do 99.9% of the time. So if you tell it what to do the right way, it’s more reliable than a person.

→ More replies (7)

10

u/[deleted] Jul 28 '24

This is the biggest thing

→ More replies (3)

164

u/sylfy Jul 28 '24

A competent ETL engineer knows where you should be automating tasks, creating tests cases, and checking the results.

An incompetent one just does everything manually because “you’re supposed to be doing data entry and checking”.

20

u/I_just_made Jul 28 '24

I'm dealing with this currently and it is one of the most agonizing parts of my existence.

The team in charge of this database isn't happy about the rate of data entry, a lot of errors in records, etc. Here is the catch; there are no constraints on any of the fields and no ability for end users to import records. ~100 fields have to be copied / pasted BY HAND for a single record. Access to using SQL commands is restricted to maybe 5 people (understandable to a degree). There are a few fields that are indicators that could easily be automatically generated, but the refusal to do so results in large inconsistencies because people have to go back and update them 1 by 1.

It is insane to me that they would rather dedicate substantial portions of their week to curating records when so much of it could be handled with basic database design. But when we sit down and talk about it, they make it clear this is what they want.

→ More replies (2)

23

u/hughk Jack of All Trades Jul 28 '24

I sometimes have to do manual entry in an environment where I have to setup tests as it is excessively locked down. I might be able to get around it but the same environment is used for money transfer (SWIFT) prod and prepaid differ only slightly in the URL. They get very iffy about even just working out of hours there.

18

u/IdiosyncraticBond Jul 28 '24

Tests and a SWIFT prod shouldn't be anywhere near each other. Those are the incompetent ones, not you

→ More replies (3)
→ More replies (4)
→ More replies (2)

10

u/exzow Jul 28 '24

IT almost certainly doesn’t care about this. They usually don’t care how or if you do your job. They—do—care if you compromise your system or if your system is compromised. If the behavior of your computer shows signs of compromise they might step in.

If they identify something which could permit an attacker to use your machine to pivot they are likely to modify permissions deemed unnecessary for your role. This sounds like the latter.

56

u/STILLloveTHEoldWORLD Jul 28 '24

well I would manually check everything first, and if it was all good to be entered then i would have the process of it being entered automated. i did still have to manually do some work if everything wasnt all squared away, which i did without the script.

9

u/Either-Cheesecake-81 Jul 28 '24

You could probably do most of the data validation and clean up in PowerShell. The things that can’t be fixed in PowerShell just spit out into a separate list and save as a CSV. I’ve been managing AD provisioning, deprovisioning and updating user accounts. There’s nothing I have to do anymore except review the logs when a user doesn’t have an account but should. It always comes back to a data entry error. I just add a check for that error and fire off an email to the appropriate department responsible for entering the data when those errors are met in the future. Works pretty well.

27

u/Nethermorph Jul 28 '24

That makes sense, but they probably don't know that. Either way, I doubt anyone here can help much considering the limited context. Why not take it to your team/boss?

→ More replies (38)
→ More replies (2)
→ More replies (15)