DEV Community

Moon Light
Moon Light

Posted on

# I Accidentally Rebooted Every Client Machine at 2PM (And Watched Chaos Unfold)

There are mistakes.

There are bad mistakes.

And then there are:

👉 “Career-defining MSP mistakes.”

This is one of those.


😌 The Calm Before the Disaster

It was a normal day.

Tickets were under control.
Clients were quiet.
Nothing was on fire.

Which, in MSP life, usually means:

👉 Something is about to go very wrong.


💡 The “Brilliant” Idea

I had a simple goal:

👉 Reboot a few machines that hadn’t restarted in weeks.

You know the type:

  • 47 days uptime
  • Weird performance
  • “Have you tried restarting?” always works

So I thought:

“Let’s automate this with PowerShell. Easy win.”


🧠 The Plan (What I thought I wrote)

  • Identify machines with high uptime
  • Reboot only those machines
  • Do it safely
  • Look like a hero

😎 The Script (What I actually wrote)

```powershell id="oops01"
$computers = Get-ADComputer -Filter *

foreach ($computer in $computers) {
Restart-Computer -ComputerName $computer.Name -Force
}




Yes.

No filtering.

No conditions.

No mercy.

---

## 🖼️ My Brain at That Moment

---

## 🚀 Deployment

I ran the script.

Sat back.

Expected… nothing dramatic.

---

## ☎️ Minute 1: Silence

Everything seemed fine.

I thought:

> “Nice. Clean execution.”

---

## ☎️ Minute 2: The First Message

> “Did our system just reboot?”

Hmm.

Weird.

---

## ☎️ Minute 3: More Messages

* “My computer just restarted??”
* “We lost our work!”
* “Is there an outage?”

---

## ☎️ Minute 5: Full Panic Mode

Slack exploded.

Phones ringing.

Clients confused.

Managers asking questions.

And me?

👉 Staring at my script like it personally betrayed me.

---

## 🖼️ Reality Sets In

---

## 💀 The Realization

I didn’t reboot *a few* machines.

I rebooted:

👉 **ALL. OF. THEM.**

* Active users
* Servers (thankfully not critical ones… barely)
* Machines in the middle of work

Basically:

👉 If it existed… it restarted.

---

## 🤦 The Root Cause (a.k.a. My Brain Failed)

The issue was painfully simple:

👉 I skipped the filtering step.

No uptime check.

No targeting.

Just:

> “Hey PowerShell, restart EVERYTHING.”

And PowerShell said:

👉 “Say less.”

---

## 🛠️ Emergency Response

At this point, there was nothing to stop.

The damage was already done.

So I switched to:

👉 **Damage control mode**

* Apologize internally
* Check critical systems
* Make sure everything comes back online

And most importantly:

👉 Never make this mistake again

---

## 🧠 The Fix (What I SHOULD Have Done)

Here’s the corrected version:



```powershell id="fixreboot01"
$computers = Get-ADComputer -Filter *

foreach ($computer in $computers) {
    $uptime = (Get-Date) - (Get-CimInstance Win32_OperatingSystem -ComputerName $computer.Name).LastBootUpTime

    if ($uptime.Days -gt 14) {
        Restart-Computer -ComputerName $computer.Name -Force -WhatIf
    }
}
Enter fullscreen mode Exit fullscreen mode

🔐 Even Better (Safe Mode)

```powershell id="fixreboot02"
$confirm = $true

if ($confirm) {
Restart-Computer -ComputerName $computer.Name -Force -Confirm
}




---

## 😂 What I Learned (Painfully)

### 1. Never trust yourself at 2PM

That’s peak overconfidence hour

---

### 2. Always use `-WhatIf` first

If you skip this:

👉 You’re gambling

---

### 3. Filtering is NOT optional

“Run on all machines” is rarely the right choice

---

### 4. PowerShell does exactly what you tell it

Not what you *meant*

---

## 🧘 Final Thought

That day, I didn’t just reboot machines.

👉 I rebooted my ego.

Now, every time I write a script, I ask:

> “Would I bet my job on this?”

If the answer is no…

👉 I don’t run it.

---

## 👇 Your turn

* Ever deployed something you instantly regretted?
* Ever taken down more systems than you intended?

Tell me your worst story 😅
Enter fullscreen mode Exit fullscreen mode

Top comments (0)