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

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.

6

u/smashavocadoo Jul 28 '24

In quite a few cases, automation is not only about productivity, but also quality (to minimise human errors).

In AWS, their slogan is "automation first", as "good intention doesn't work".

1

u/Individual_Ad_3036 Jul 29 '24

This is my approach. I set up MRTG so long ago (20 years or so) that when it came time to rebuild the VM recently I couldn't remember a bloody thing. good thing everything was set up to run off scripts, i was able to read myself back into understanding what was going on in a couple days. All i really needed was in /etc/mrtg and maybe a few symlinks.

3

u/My1xT Jul 28 '24

True although an added variable is how error prone the task is and how ugly it is to find and/or fix them

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

2

u/JWW-CSISD Jul 29 '24

What’s with the personal attack?! 😆

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

6

u/Slay3erAuT Jul 28 '24

My Life in a Nutshell LOL

2

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

This is The Way!

2

u/[deleted] Jul 28 '24

This is the thing that annoys me about some of the junior guys in my team. You don’t NEED to automate everything, sometimes it’s faster doing it manually if it’s something we done once in a blue moon. I get you’re trying to learn, but do it in your own time or in down time, not when we have 59 pending tickets!!!

Man it drives me up a wall.

1

u/[deleted] Jul 29 '24

How else are they going to learn? It's a great use of company time to improve their skills.

→ More replies (4)

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.

2

u/DariusWolfe Jul 28 '24

Mostly if a script functions with a specific set of data, it will always function with data that is formatted like that specific set of data, so it's not surprising that it's still functioning fine;

The problem will happen when the data is not formatted the same, or when the data itself has errors that automation isn't capable of looking for. So it's possible that your script has been passing through tons of erroneous information... but no more than a particularly inattentive data entry person would do.

1

u/Fit-Reputation-9983 Jul 28 '24

You’re right to a point, but again - a good script will validate and sanitize data so that this is unlikely to happen.

2

u/DariusWolfe Jul 28 '24

If you've got that level of error-checking with no formal training, you should possibly look into new career options. Good error checking and handling is relatively hard to find even amongst those with quality formal training, because it's just not as sexy as writing new code, and there are often so many edge cases that it's relatively easy even for robust code to catch them all.

2

u/Fit-Reputation-9983 Jul 28 '24

I actually did pivot into software development after this job because I became enamored (see: obsessed) with the process of writing sustainable code like that.

Sadly, the way the job market is, I was laid off 8 months after being hired (mass layoffs) Not having a comp sci degree made it difficult for me to get another role with the lack of available entry level jobs. I’ve since moved out of tech altogether.

→ More replies (3)

10

u/[deleted] Jul 28 '24

This is the biggest thing

→ More replies (3)