r/PowerShell • u/BaDumDumTish • Apr 21 '21
"Your stupid PowerShell script is broken."
That was the title of an email I received this morning from a newly hired manager. Never dealt with them directly before, but I'd heard rumblings from others he was 'difficult' to deal with. The manager who wrote the email also CC'd the IT Group of some thirty people covering HQ and three other offices from the VP of IT down. This resulted in a high-pri ticket with my name on it.
This concerned a simple piece of PowerShell code, you type in your email address and the OU site you wanted queried and it sends you the group member list of the AD Groups in that site via email. There's no read me file. The people who need it know how to use it. It's used by the security auditors to make sure the right people in that site are in the right OU's. The scripts are in a group folder that are available to management at the company. When the script is run (It's called "SiteReview.ps1"), the prompts show in the PS Window as:
**** Site Review v1.02 ****
**** In case of issues contact (My name & my email) ****
Email: (Pause for input)
Site: (Pause for input)The email said that this manager could not get "any usable output" from my script then went on to berate me for "wasting their time" with "such unproductive software". This really surprised me as I had not touched that code in over three years and it was used quarterly by the security auditors. I had built in logging that dumped results into a separate file folder only available to IT so that was my first stop.
The first part of the SiteReview.log file was typical, my early tests and past security output ; so I slid down to the more recent time / date stamps.
This (edited for readability) is what I found:
Email: (Managers email)
Site: (XXX site 1)
Error message "Get-ADSite : Directory Object not found..."
Email: (Managers email)
Site: http://(XXX site 1)
Error message "Get-ADSite : Directory Object not found..."
Email: (Managers email)
Site: https://(XXX site 1)
Error message "Get-ADSite : Directory Object not found..."
Email: (Managers email)
Site: www.(XXX site 1)
Error message "Get-ADSite : Directory Object not found..."
(Twenty-two more entries involving four more XXX sites) My boss came up to my desk for an update just as I found the above and one glance raised eyebrows. They asked me to forward the log to their email.
Just before closing I was messaged to close the ticket and "not worry about it."
47
u/Tymanthius Apr 21 '21
We definetly need an edit to clarify if (XXX site 1) = porn.
7
u/pppppppphelp Apr 22 '21
you'll always be surprised what shows up on a vpn because people wfh...
7
u/Tymanthius Apr 22 '21
Not even a little bit. Seen it IN THE OFFICE at state gov.
2
Apr 28 '21
If you're in government and you know even trying to fire you is three hours of paperwork your boss doesn't want, and likely wouldn't be approved anyway... YOU'RE FREE! LET'S HAVE AN ORGY IN THE CONFERENCE ROOM!!!
1
u/Tymanthius Apr 28 '21
Almost. That would probably get you fired if only b/c the news would get ahold of it.
1
33
u/Content-Appearance97 Apr 21 '21
Well, I know things are "not the same everywhere", but if I was your boss I would be formally requesting an apology for the unprofessional behaviour towards you - an organisation where that kind of attitude is accepted is not a healthy one IMO.
4
u/craftbrewbeerbelly Apr 22 '21
My reply all to that email would literally just be, “Is this how you think adults are supposed to behave?”
8
u/Content-Appearance97 Apr 22 '21
There have been lots of suggestions for a direct retort in this thread - most of them a lot cleverer than I could come up with! But leaving aside the personal satisfaction it's really not the best approach. Really the OP should discuss it with the line-manager and raise it with HR who should take it seriously. (Note that I'm talking about the tone of the original email, the fact the instigator may have been checking dodgy sites is actually irrelevant to this aspect of the complaint.)
Of course, that relies on the OP working in a healthy organisation who care about workplace culture, If not, you're a bit stuck.
30
u/gordonv Apr 21 '21
26 porn site entries and a mass forwarded email. All time stamped.
So maybe you can track the amount of time from the last porn domain to the rage-mail.
Heck, track it from the creation time of his AD User account. And account deactivation. His literal career.
85
u/apathetic_lemur Apr 21 '21
I've dealt with these users and I'd just email him back (along with all the CC's) and ask which part of my stupid script he was having problems and a screenshot of the logs. Someone you dont even know, that is new to the company, comes out swinging like a fucking asshole doesnt deserve a shred of restraint on your part.
28
u/MrWinks Apr 21 '21
Deserving is one thing, but the company won’t like seeing you with-holding restrait over a personal issue. Always always always deal with these confidentially. In the best case, the right people know and if asked you can vaguely and tactfully explain how it was an error in judgement. Avoid attacking others at work, as it’s unmistakable when done in just retaliation this way, even when deserved.
Though, if your boss ever gives you the approval to blast way, that’s always the best ;)
3
u/apathetic_lemur Apr 22 '21
i dont know. Every work place has a huge asshole or two that for some reason dont need to worry about tact and they do fine. Occasionally returning fire doesnt seem so bad.
10
u/stone500 Apr 22 '21
People definitely deserve it, but I don't think there's ever a scenario where your manager says "Hey it was really good how you gave that guy the business and embarrassed him in front of everyone so we wanted to give you a bag of money and a nice promotion"
Professionalism is always always preffered. Definitely notify your boss of the situation, but there's no benefit to calling him out publicly. If personal issues persist then you notify your manager, HR, and his manager if necessary.
7
u/Letmefixthatforyouyo Apr 22 '21 edited Apr 22 '21
I disagree. Occasionally, you have to throw an elbow to make it clear to people that if they come after you, you will hit them back. It means you will have to deal with way less elbows in the future.
The key is to be calm and professional in the response. A simple
"hello X,
This is a tool used to search an ADsite group based on a submitted user query. Based on the logs generated, it appears that you were trying to access various adult web sites with your work login, see attached. Please note that this tool will not return data for any website, adult or otherwise, as its specific to our internal active directory. If you have any further questions or concerns about this tool, please let me know. Id be glad to answer them."
Calm, direct, but also specifically showing he was trying to hit pornhub/etc. It demonstrates competency, clears your name, and shows IT can generate receipts when people make bold claims. Thats a win win win.
3
u/Jolape Apr 22 '21
Exactly. I don't think teaching people a lesson is unprofessional. If the manager had wrote the mail respectfully requesting assistance, then yes, it would be pretty unprofessional to reply-to-all with the details of what you found in the log. But if he's going to come out insulting you and putting your work/expertise in question in front of everyone, then it's on him when he gets called out.
2
u/stone500 Apr 22 '21
That's fair, though I would leave out the detail that it's adult websites. I'd keep that little bit iny pocket to use later.
The way I'd word it is "I can from the logs that you were trying to use this tool with certain websites. I can go over these logs with you and I can show you exactly what you're doing incorrectly."
1
u/Letmefixthatforyouyo Apr 22 '21
Judgement call, but id say it demonstrates poor judgement on their part, which is something you want to highlight in these situations.
Note that nowhere did I make a specific statement calling him out for querying porn on his work PC, as thats not ITs role. I just made sure that information, that was 100% part of the issue, was clearly visible to the 30+ people he decided to tag in this email. If they want to make a judgement on it, thats of course up to them.
1
u/stone500 Apr 22 '21
Note that nowhere did I make a specific statement calling him out for querying porn on his work PC
Based on the logs generated, it appears that you were trying to access various adult web sites with your work login, see attached.
2
u/Letmefixthatforyouyo Apr 22 '21 edited Apr 22 '21
Yes, exactly. Thats making it clear the sites were adult, but im not specifically stating right or wrong in a company context.
A call out would be:
"Please be aware that querying or otherwise visiting adult websites is agaisnt our computer use policy. The servicedesk will reach out to schedule a mandatory virus scan of your system shortly. To stay in complaince with company policy, refrain from interacting with adult sites in the future. Failing to do so may result in escalation to HR and possible termination."
The above is me forcing consequences and issuing ultimatums, which is directly advisarial and may be out of scope of my role. That is an option, but goes well beyond the "dont put me on blast or it will hurt" elbow I prefer.
-1
u/S-WorksVenge Apr 22 '21
Missing an apostrophe in a professional email... not a good look.
4
u/Letmefixthatforyouyo Apr 22 '21
Yeah, this is a reddit comment, not a professional email. You can tell because its a comment on reddit.
An email would be formatted and proofread for grammitcal errors. This was not.
0
u/S-WorksVenge Apr 23 '21
You tried really hard to be professional and ended up using a lot of words to sound not only unprofessional but dumb. Hopefully you're not sending anything close to these out. You also missed an apostrophe in a word, a common mistake.
1
1
u/stuart475898 Apr 22 '21 edited Apr 22 '21
Lol - my sarcasm-o-meter lit up when I read this reply. An expertly crafted comment indeed.
4
u/stuart475898 Apr 22 '21
I know what you mean, but disagree. I’ve jumped on the reply all train previously to defend myself from a public criticism, but since then and having seen these emails and responses as a spectator, not doing the reply all thing is much better. I think when most people see a widely circulated email publicly criticising someone, they see it as just that - an unprofessional email where the sender looks bad. Admittedly when you’re the subject of criticism, it’s hard to be restrained and see it that way, but I think those who then think less of you based on that email alone are the minority. And even then, you replying all and the sender getting a load of egg on their face is unlikely to change their view.
Nobody comes out of a shit slinging match clean. Don’t reply, take the discreet and tactful approach, and most will forget about it or just think the sender is a knob. Ride that moral and professional high-horse into the sunset.
1
u/ka-splam Apr 22 '21
Nobody comes out of a shit slinging match clean.
Sadly, yeah.
Reply all: "You know the drill - raise a support ticket and we'll fix it".
1
u/MrWinks Apr 22 '21
I have not encountered anything remotely like that. Military levels of tact have seemed required.
50
Apr 21 '21 edited Nov 27 '24
rob quack toy divide smoggy bake snatch zesty attempt deranged
This post was mass deleted and anonymized with Redact
44
u/CitySeekerTron Apr 21 '21
Sounds like your script is working as intended. Submit this to your boss as directed, and then proceed as needed. Not your circus, not your monkeys.
And definitely not his circus.
38
u/Mental-Writing-6189 Apr 21 '21
My guess, this new manager won't last long.
85
u/apathetic_lemur Apr 21 '21
or he'll be promoted multiple times within a year
15
u/ipreferanothername Apr 21 '21
yeah i would guess this - i have my eyes on a guy at work who will make an excellent VP candidate one day because he is very personable and knows fuck-all
2
u/nascentt Apr 22 '21
yup more likely this. at least in every case I've seen so far.
The only people getting fired are the poor saps they guy throws blame onto for their "stupid" work.
1
14
Apr 21 '21
I'm confused, what exactly was this guy attempting to do? Like... what did he think this script was supposed to output with a porn URL as input?
22
u/elementfx2000 Apr 21 '21
I'm guessing he thought "sitereview" was a way to check a user's browsing history. So he was checking if the company had record of him visiting those sites, which they probably didn't, but now they do.
8
u/purplemonkeymad Apr 22 '21
Maybe he was looking to see if the sites were any good, gotta find the best reviewed site!
I think I have the prefect the script for him:
function Get-SiteReview { Param( [parameter(Mandatory,HelpMessage="Your email address")][string]$YourEmail, [parameter(Mandatory,HelpMessage="The site uri")][uri]$Site ) $ReviewScore = ([security.cryptography.sha256managed]::new().ComputeHash([Text.Encoding]::Utf8.GetBytes("$Site"))[-1] % 5) + 1 Write-Host "$ReviewScore/5 $( ('★'*$ReviewScore).padright(5,'☆') )" }PS, turns out the OP's post is a 5/5!
1
u/Tech_surgeon Apr 22 '21
sounds like a case of the some one that only claims to know what they are doing. these are the same people that can weaponize a deployment script and try to claim it was something else when they wipe half the computers.
13
24
Apr 21 '21
Wait is the XXX like porn site or just filler for real name?
11
u/Mkep Apr 21 '21
I believe porn or inappropriate, based on the script name being “SiteReview”
8
u/dylbrwn Apr 21 '21
I think that's in reference to Active Directory Sites
15
u/Mkep Apr 21 '21
Yep, I think the original script is meant to review AD sites, but the manager in this case though it was WebSite reviews
3
9
u/HappyDadOfFourJesus Apr 21 '21
Damn, I don't even know of 26 XXX sites. This guy needs more work to do...
22
u/Xibby Apr 21 '21
Setting aside the disrespectful comments from the manager.
PowerShell Comment Based Help is how most of my scripts are documented. Maybe there is a README file in the Git repository.
1
u/nascentt Apr 22 '21
I do this and I also have a scheduled script running that Get-Command all the commands in the company and generated html help files for each command to generate readmes for each command. It's great cause it's auto updating so if new code is made or old stuff removed the help files are up-to-date
15
u/Jolape Apr 21 '21
Wow.... You're a better person than me I think. If someone did that to me, I would have replied to all and apologize first and foremost that I didn't make the script idiot proof. Then I would have explained that it's for AD sites, and not pornography web sites with a screenshot of the log.
3
u/L33Tech Jul 14 '21
Hey OP, this has been reposted without credit.
https://www.theregister.com/2021/07/12/who_me/
https://www.reddit.com/r/PowerShell/comments/ojt755/the_register_has_stolen_a_powershell_story_and/
Just wanted to let you know!
24
u/BaDumDumTish Jul 14 '21
I submitted it to them last week. Thanks.
4
Jul 14 '21
See they've now added a header:
Hi there, Reddit. The following tale appeared
on Reddit some months ago, and the original poster then submitted it to
us with some extra detail. Usually, while we're verifying submitted
stories, we check that the yarns haven't been published elsewhere, and
in this case we simply forgot to. The OP confirmed here that they posted it to Reddit and then submitted it to El Reg. Stolen content, this ain't – ed.2
12
u/IOnlyRoll20s Apr 21 '21
do u work at pornhub?
but seriously was he just being goofy or what was he trying to accomplish by putting some porn site in your script?
9
u/marcdk217 Apr 21 '21
I would have found it very hard not to reply all with:
Hi,
My stupid script appears to be working correctly, however the stupid user appears to not understand how to use it.
(unless it was my own manager of course)
3
2
Apr 21 '21
Ah yes, a PICNIC error.
4
3
1
u/nascentt Apr 22 '21
I too would've had trouble not replying, but the last time I did (and was pretty professional about it) the shitty person doubled down, ran to his manager and then I ended up getting told off for it.
So now I just "fwd: " and "fyi" to my manager and let them deal with it.
Once the guy threatened to punch my colleague in the nose because he (the user) had forgotten his email account password.
He's still with the company of course.
7
u/Anlarb Apr 21 '21
Everyone getting excited about XXX, thats not the joke, thats filler. The joke is immediately preceding it, here is how an OU is formatted.
https://theitbros.com/active-directory-organizational-unit-ou/
4
4
4
Apr 22 '21
Run a different script on this guys pc that moves his mouse by an inch randomly 2-3 times a day 🤣🤣
2
u/signofzeta Apr 21 '21
Did you ever find a suitable replacement for the deprecated Send-MailMessage?
2
u/nascentt Apr 22 '21
today I learned that Send-MailMessage is deprecated
Warning
The Send-MailMessage cmdlet is obsolete. This cmdlet does not guarantee secure connections to SMTP servers. While there is no immediate replacement available in PowerShell, we recommend you do not use Send-MailMessage. For more information, see Platform Compatibility note DE0005.
Still rely on it here. Luckily it's not used for anything that needs to be secure, and if it was email wouldn't be used in the first place.
2
u/InsrtCoffee2Continue Apr 30 '21
You can fix your script to only accept certain values but than again you already mentioned those who need it know how to use it. Even if you did make the changes... who knows if they would still get it. You can't fix stupid.
3
3
2
u/motsanciens Apr 22 '21
"I'm sorry - the interface is probably not clear for new users. The 'site' the script prompts for expects an Active Directory OU. Would you please run the script and use <some ou here> from your machine so I can check the logs to be sure there's no issue?"
Now everyone knows
you're not a dick; he is
the script works as intended for the people who know how to use it
his fuck-ups have been logged
1
1
1
u/guitpick Apr 21 '21
You should create AD sites with some of those names so that your stupid PowerShell script will work. And put his computer in one of them.
1
u/Alaknar Apr 21 '21
Wait, I'm a bit lost here - is "XXX site one" supposed to mean "first porn site he typed in" and then there were more of those? Or is "XXX" just "crossed out name"?
1
1
Apr 28 '21
It's probable that he thought, based on the name "Site Review", that this script he ran across was going to show him reviews or web reputation information. It's possible that he was plugging in "known bad" sites to test it. Still an asshole for the email, and a bit of an idiot, but maybe not actually surfing porn at work.
1
u/Saad-Ali Jul 14 '21
Why keep this ah finder powershell to yourself. Please share , perhaps we may as well some ah that we aren't aware of.
1
u/rubmahbelly Apr 21 '21
The definition of insanity: trying something again and again with the same input and expecting a different outcome.
Get-AdUser -Identity dumbfuck.manager | remove-aduser
5
u/Tymanthius Apr 21 '21
He actually didn't use the same input. He just used the wrong class of input.
6
1
u/MonopolyMeal Jul 14 '21 edited Jul 14 '21
Wow, the Register has stolen this story and plagiarized it for their own greed!
https://www.theregister.com/2021/07/12/who_me/
Edit: Not Stolen as other Redditors have found. I jumped to conclusions as I have seen stories from various Reddit posts get snatched up and regurgitated on various sites. I thought this was another instance.
3
0
1
u/TheHeffNerr Apr 22 '21
I would have not restrained myself. I loved getting emails like that... "loved"... :(
1
1
1
1
Apr 22 '21
Good on you for remaining professional. That has been my biggest challenge at work is not going nuclear on people when they try to toss my team under the bus. I’m prior military and accustomed to being able to argue in an unprofessional manner. All that said, you showed an enormous amount of restraint and I commend you for it. Honestly, I don’t think I would’ve been able to stop myself from replying all and going scorched earth to include all of the XXX sites you found in the log to air out his dirty laundry in the most embarrassing way possible. I can only hope that someone reigns this manager in and he stops burning bridges with your department.
1
u/z_agent Apr 22 '21
accustomed to being able to argue in an unprofessional manner
I need that as a warning on my door!
1
1
u/rick_D_K Apr 22 '21
Reply all: you are entering websites This script is for physical business locations.
P.S. never run scripts you don't explicitly understand.
1
u/lavahot Apr 22 '21
I'm confused. What kind of output was he expecting by querying an external domain?
1
0
u/Skaixen Apr 21 '21
You should build out a GUI for your script.
Textbox entry for the email.
But a dropdown box, pre-populated with the available sites.
This way, they can't put in bad information for the site.
5
1
u/Loan-Pickle Apr 22 '21
I generally do input validation on my script. Except for when I’m in a hurry and need to knock out something quick. Of course those are the scripts that everyone and their mother ends up using. Then I never have time to go back and fix it.
0
u/user_josht Apr 22 '21
Funny find on the xxx sites, but why didn’t you just mass reply, “Maybe you’re too stupid to use it”? Just because you’re in IT doesn’t mean you have to break your back being overly accommodating. If someone sent one of my employees an email like that I would be calling them for an earful. Whoever your boss is needs to grow a spine.
0
u/Swarfega Apr 22 '21
How is management allowing someone in their company to even write an email with a subject like that? That guy needs to be given the chop.
0
u/mangopurple Apr 22 '21
Take that ‘manager’ to HR.
Technical knowledge or not, the guy is clearly an assclown.
0
0
u/drumsand Apr 22 '21
And some people ask me why I take time to make each and every and even smallest of my scripts to use module to save logs.
Each time, from any location by any user script is run... :)
There were few occassion I could send logs and say it in Bugsy voice:
"Here you are, sweetheart"
0
0
Apr 22 '21
I mean the manager is definitely acting stupid but if it's intended for public use it's always nice to include some directions to how to format input and such.
0
u/Substantial_Plan_752 Apr 22 '21
Please for the love of christ stop saying high-pri. Otherwise this us hilarious.
0
Apr 22 '21
Soooo...the manager put that abuse in an email? Sorry for him. HR should know about this communication.
0
u/needssleep Apr 22 '21
Bro, how you gonna provide a funny story about an awesome script and then not share the awesome script?
0
0
u/Whatsitforanyway Apr 22 '21
I had a similar issue one time with a sales guy at my company. This was many years ago and we were developing a laptop backup system that I maintained the database for. We had a hold on any restores as it periodically went into a holding pattern while the devs did updates. This guy was mad because he lost some files for his client and needed a restore. He called up the ceo of the company raising hell and bad talking my boss. So we had to make an exception and dump all his files onto cd. Well, the files mostly consisted of thousands of porn images so I made up the cds and took them and the file listing to my boss. She delivered the data to the ceo. Needless to say the guy swore it wasn't his files and he was a happily married man. Yeah, ok. He had to find another job.
0
u/scoobydoobiedoodoo Apr 22 '21
Congrats on the win! By any chance can you share this script? It sounds like something I could use and didn’t realize it until you shared your story. If not, it’s cool too.
0
u/idrac1966 Apr 22 '21
I wonder if he was also being an asshole to his colleagues and they played a prank on him.
"Yeah man, just put whatever website you want into this script and it will tell you if it's flagged on the company firewall. Works fine for us we use it all the time."
0
0
0
Jul 14 '21
[deleted]
1
u/BaDumDumTish Jul 14 '21 edited Jul 14 '21
Or it was submitted by me directly. Seems the more logical thing.
The Register is a reputable IT based news site and I doubt they would ever need to "steal" anything for content.
143
u/AirExplosive Apr 21 '21
I mean, congrats on having the restraint to not just, copy those logs out and blast them out on a passive-aggressive reply-all—“These are the logs that were generated, could you confirm if this was the input you were providing to the script?”
Although there’s the “anyone coulda put my email” unless you were logging the user/pc running the script too