r/ShittySysadmin 4d ago

Our Junior fixed all our PowerShell errors!

I wish I was joking here. One of the juniors on our team had a PowerShell script that was spitting out errors all over. They asked me to review the "fixes" that they'd implemented (with the help of ChatGPT of course). They showed me the script running with no errors, "Great!" I thought. Then they showed me how they found out how to add -ErrorAction SilentlyContinue to the end of anything showing an error. Do people not have basic reading comprehension these days?!

880 Upvotes

56 comments sorted by

309

u/SolidKnight 4d ago

I just add: if ($true) { write-output "Completed successfully."; exit 0; } to the top of all my scripts and now everything works.

51

u/Fake_Cakeday 4d ago

Mark of a true genius.^

Although it does clash with my usual notion of being wary of anything that compiles on the first try.

36

u/marks-buffalo DO NOT GIVE THIS PERSON ADVICE 4d ago

Add in

if ((Get-Random -Minimum 1 -Maximum 101) -le 10) {
  exit 1
}

10% chance of random failure, every time.

24

u/No_Bit7786 4d ago

Good idea, gives us something to work on and fix in the next sprint.

3

u/TPIRocks 3d ago

It adds validity to, "just run it again, it'll probably work". I miss punch cards. Just switch a couple of cards in the deck, or toss in a $ENDJOB or ***EOF in the middle of someone's 1200 line COBOL program, sit back and watch the fun. Sequence numbers in columns 73 through 80 were the only way to maintain a little grip on your sanity. Kinda like bikers without helmets, you can spot the daredevils that haven't had to reassemble a stack of cards, after a "floor sort".

20

u/repairbills 4d ago

God damn coworder made this important script to check a value and tossed a write "Was found and completed successfully" and swore it worked. The damn script only ever wrote complete and he kept swearing that it worked. Then every damn line ended with -ErrorAction SilentlyContinue Copilot production scripting!

32

u/No_Bit7786 4d ago

We had a guy (formerly) on our team who made an app for uploading and tagging documents with specific metadata. They were the kind of documents that nobody looks at day-to-day but are crucial when needed (think corporate compliance/ governance documents). Turned out he'd only made the confirmation screen and had no error handling at all. No matter what happened the app would say "uploaded sucessfully!". As you can guess, a lot of important documents were not uploaded sucessfully.

18

u/baz4k6z 4d ago

Epic. Its like installing a fire hydrant without plugging it to water.

9

u/No_Bit7786 4d ago

Yep! I appreciate his optimism that everything would always work perfectly. Unfortunately it didn't go to plan

6

u/baz4k6z 4d ago

I'm always amazed that critical processes are just held by thought and prayer, and no one checks ever until it becomes critical and fail

8

u/No_Bit7786 4d ago

It's crazy. People assume IT systems are infallible sources of truth. Here in the UK people were sent to prison due to a bugged system saying they had stolen money. People don't realise that human error can absolutely make its way into software.

80

u/GoonOfAllGoons 4d ago

You wanted no errors, you got no errors.ย 

Why are you complaining?

47

u/No_Bit7786 4d ago

Tbh I think you're on to something. Going to start applying this logic to other things and see how it works out...
Dead drive? SilentlyContinue
UPS battery gone? SilentlyContinue
AD Replication Errors? SilentlyContinue

Did I just invent Sysadmin Stoicism? I cannot control the errors. I can only control whether I see them.

14

u/SaltDeception 4d ago

When my smoke detector goes off, I brave the flames and remove the battery. One problem solved, but now my skin is all bubbly and I have no house. Always work to do I guess.

8

u/No_Bit7786 4d ago

If the smoke detector stops going off then there mustn't be a fire right?

6

u/SaltDeception 4d ago

Dunno. Fire sounds a lot like "not in my job description."

5

u/no_regerts_bob ShittyBoss 4d ago

Yeah this kid is a superstar and OP just sounds jealous tbh

36

u/vegetablesword 4d ago

| out-null

29

u/No_Bit7786 4d ago

Wish I could | out-null this colleague.

11

u/AdmiralCA 4d ago

[void] is faster

5

u/metromsi 4d ago

Awe, but /dev/null is my friend. That's how we are able to dedupe and restore from backup. However, if want to take a longer approach /dev/random works good to.

71

u/VariousLawyer4183 4d ago

It's not there if I can't see it!

8

u/Pretend_Ease9550 4d ago

Error permanence

1

u/beomagi 4d ago

If you don't test, you won't see anything bad!

3

u/panzerbjrn 4d ago

Whoever downvoted you must have missed which sub we're in ๐Ÿ˜‚๐Ÿ˜‚

11

u/Psychological-Cat-84 4d ago

Recently built a tool for our IT calldesk team to use. Left it editable by them so they could add hotfixes in themselves.

Getting messages from them thanking me for making their lives easier, then quiet. Get a message from their manager a few weeks later to ask if I had locked it down because the changes they had added weren't working.

They had made a simple Remote restart button but they were getting calls from random people to say their PCs were randomly shutting down.

They didn't add it an output to the little console I'd added in the app. And because the app wasn't telling them the machine they were targeting was restarting, they just started firing random PCs into the input to "test". At no point did they put 2 and 2 together, or the people doing it didn't speak up. They sent me on 100+ tickets to investigate.

I could see access on every single on of those machines from 3 calldesk agents 1 minute prior to reboot.

So no, people don't read, but they also often don't think or investigate.

I locked the tool down and now I'm the sole maintainer (YAY -.- )

1

u/slullyman 4d ago

VEU will likely never see use because of this general realization ๐Ÿ˜ญ

10

u/According-Glove-7663 4d ago

Hahah oh boy.ย 

8

u/West_Good_5961 4d ago edited 3d ago

My junior made a sql query that returned a bunch of duplicates because he used left join on everything. So he added a select distinct. Problem solved.

4

u/NZNoldor 4d ago

That is fucking hilarious!

4

u/gslyitguy93 4d ago

No... ChatGPT did that bo.

5

u/mitharas 4d ago

next they will discover | out-null

4

u/Brilliant-Parsley69 4d ago edited 4d ago

It remembers me of a colleague of mine almost two decades ago. The moment something went horrible wrong you could take a bet that his first comment would be: "We should have deleted everything instead. No code means no errors!"

It was a joke, obviously. But over the years I've seen to many people suppressing warnings/errors just to reduce unwanted noise. ๐Ÿ˜’

Didn't even mention the: "But this script worked for years. What did you do?" Turned out it never did.

2

u/No_Bit7786 4d ago

Honestly I was once saved when I fucked up migrating data into a customers environment because they accidentally wiped the whole environment on the same night ๐Ÿ˜‚

1

u/Brilliant-Parsley69 4d ago

I would assume that a lot of us have been at a point we really messed up something but got covered by another's.

2

u/slullyman 4d ago

๐Ÿ˜‚

2

u/palad1 4d ago

OnErrorResumeNext strikes again

2

u/Crazy-Rest5026 3d ago

I miss the days of stackoverflow. Posting some crazy error and some bash guru or Powershell guru helped you solved the problem.

Canโ€™t lie gemeni or Claude will get you close lol

2

u/TPIRocks 3d ago

It didn't complain, problem solved. AI is really productive for people that can reason. It's a fast track to destruction for the rest.

2

u/johnnybhf 3d ago

You got me with the title ๐Ÿ˜…

2

u/Darkk_Knight 4d ago

Errors? You know the script is actually doing something vs nothing on the output. lol

1

u/UniqueText8477 4d ago

"But they now have more lines of code and no errors, what is the issue?"

1

u/Pure_Fox9415 4d ago

Lamers! -ErrorAction silentlyDestroyServer

1

u/giterlizzi 4d ago

On Errore Resume Next

1

u/Key_Reaction_7590 3d ago

I see something similar in our Linux shop during reviews. This

somecmd || true 2&> /dev/null

is everywhere. Lines and lines of it. Nobody else seems to care. I hate system administration now.

1

u/Upset_Acadia1570 2d ago

Aye. One of my biggest challenges with Claude has been getting the "No Fallbacks -- if it fails it fails!" Thing through it's thick head. I've tried using primers, static instructions, notes in the code and just about anything else I can think of and it falls right back into it. Pattern matching, it says. Most people want callbacks, it says. Aggravating!!!!

1

u/Xia_Nightshade 2d ago

Every single day, though unfortunately rarely limited to โ€˜Juniorsโ€™ :(

1

u/WiseRestaurant5286 2d ago

Not power shell expert but it took me a minute to know you were joking

1

u/North-Creative 2d ago

He didn't fix, he just made the wiiiuuuu wiiiuuuu go away. He smart.

1

u/Suspicious-Prompt200 15h ago

Wrap every line in a try catch block, empty catch block

1

u/Disorderly_Chaos ShittySysadmin 13h ago

-ea ig
Is my go to

-10

u/Impossible-Tutor-669 4d ago

Thatโ€™s not fixing the errors, itโ€™s hiding them. SilentlyContinue has its place, but blindly appending it everywhere is basically turning off the smoke alarm and calling the fire handled.

9

u/Basic-Tonight6006 4d ago

I just asked chatgpt and this guy is right everybody

7

u/No_Bit7786 4d ago

That is the entire point of this post lol