r/PowerShell • • 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."

350 Upvotes

141 comments sorted by

View all comments

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

84

u/BaDumDumTish Apr 21 '21

;)

I omitted the IP address for obvious reasons.

81

u/[deleted] Apr 21 '21

Mate sorry but I don't get it. Did you mean a pr0n site with those XXX or was that input just a filler to not provide any details at all kinda like XYZ / ABC. Coz srsly theres so many abbreviations of all things possible I lost track a long time ago and don't take anything for granted. Coz like the last time I saw someone use XXX when mentioning a pr0n site was long before the first vin diesel XXX movie, which as I checked right now was quite some time ago.

Edit: and if they actually were pr0n sites could you please provide the links, because I can't make a final judgement on that manager before I can make a site review myself.

30

u/[deleted] Apr 22 '21

I think the funny is that the guy put in a WEB-site, not a ADSite. Funny it is indeed

12

u/Aggressive-Weekend78 Apr 22 '21

Thank you for explaining this. I was super confused why they were doing that, now I see that IS the funny.

1

u/[deleted] Apr 23 '21

The dude abides! happy scripting :D

4

u/[deleted] Apr 22 '21

[removed] — view removed comment

0

u/[deleted] Apr 22 '21

[deleted]

2

u/[deleted] Apr 22 '21

[removed] — view removed comment

0

u/[deleted] Apr 22 '21

[deleted]

3

u/[deleted] Apr 23 '21 edited Apr 28 '21

I think about this constantly, After listening to the spanish speaking Factory episode of Darknet Diaries I don't even dare post online anymore :O

Episode link: https://darknetdiaries.com/transcript/41/

2

u/[deleted] Apr 26 '21

Brazilian Factory episode of Darknet Diaries

do you mind telling me what episode that is? I did a quick search on their site but cant find anything relating to brazilian factory

1

u/[deleted] Apr 29 '21 edited Apr 29 '21

https://darknetdiaries.com/transcript/41/

Wasn't brazil, But a generic Spanish speaking country

1

u/Ok_Smile_5908 Apr 24 '21

Can't you just check the DHCP logs though to find out which device was assigned which IP? I used this once in my life because we had this one printer that would randomly switch its statically assigned IP address at random times (happened about 3 times over the course of 2-3 months). I had a gut feeling it could have something to do with the DHCP but couldn't be sure because its original IP was free at the time. Turns out a client PC got the exact same IP from the DHCP server shortly before the printer switched to a new one - someone had wisely decided to configure the static IP of the printer in the DHCP range. One final change to its IP and update on the print server later and it never happened again. Dk if that kinda log is enabled by default though but it stored information like device date and time, name, received IP.

0

u/[deleted] Apr 22 '21

[removed] — view removed comment

2

u/Thingsthatdostuff Apr 22 '21

You can pretty much assume it is... DHCP Leases/Login Scripts/DC logs, Fill in the blanks with any additonal third party software that may be used for auditing. Making a few assumptions and with the right level of administrative access. It's fairly trivial.