Live
Black Hat USADark ReadingBlack Hat AsiaAI BusinessAI shutdown controls may not work as expected, new study suggests - ComputerworldGoogle News: Generative AI27 questions to ask when choosing an LLM - InfoWorldGoogle News: LLMJapan, driven by labor shortages, is increasingly adopting robotics and physical AI, with a hybrid model where startups innovate and corporations provide scale (Kate Park/TechCrunch)TechmemeAnthropic tells OpenClaw users to pay up - The Rundown AIGoogle News: ClaudeANALYSIS: Q1 IPOs ‘Forge’ Ahead as OpenAI, SpaceX Look to Debuts - Bloomberg Law NewsGoogle News: OpenAIDeepMind Calls for New Safeguards Against AI Agent Exploitation - The420.inGoogle News: DeepMindChatGPT web service hit by brief disruption, OpenAI investigates - news.cgtn.comGoogle News: ChatGPTAgile Robots and Google DeepMind Partner on AI-Driven Industrial Robotics - ARC AdvisoryGoogle News: DeepMind40 Days of Building HarshAI: What I Learned About AI AutomationDEV CommunityMoving fast with agents without losing comprehensionDEV CommunityCharlie's Chocolate Factory Paperclip — Ep.1DEV CommunityAI-Generated APIs Keep Shipping Wildcard CORS. Here's the Fix.DEV CommunityBlack Hat USADark ReadingBlack Hat AsiaAI BusinessAI shutdown controls may not work as expected, new study suggests - ComputerworldGoogle News: Generative AI27 questions to ask when choosing an LLM - InfoWorldGoogle News: LLMJapan, driven by labor shortages, is increasingly adopting robotics and physical AI, with a hybrid model where startups innovate and corporations provide scale (Kate Park/TechCrunch)TechmemeAnthropic tells OpenClaw users to pay up - The Rundown AIGoogle News: ClaudeANALYSIS: Q1 IPOs ‘Forge’ Ahead as OpenAI, SpaceX Look to Debuts - Bloomberg Law NewsGoogle News: OpenAIDeepMind Calls for New Safeguards Against AI Agent Exploitation - The420.inGoogle News: DeepMindChatGPT web service hit by brief disruption, OpenAI investigates - news.cgtn.comGoogle News: ChatGPTAgile Robots and Google DeepMind Partner on AI-Driven Industrial Robotics - ARC AdvisoryGoogle News: DeepMind40 Days of Building HarshAI: What I Learned About AI AutomationDEV CommunityMoving fast with agents without losing comprehensionDEV CommunityCharlie's Chocolate Factory Paperclip — Ep.1DEV CommunityAI-Generated APIs Keep Shipping Wildcard CORS. Here's the Fix.DEV Community
AI NEWS HUBbyEIGENVECTOREigenvector

PowerShell Scripts Every MSP Should Use

DEV Communityby Moon LightApril 3, 20263 min read2 views
Source Quiz

If you work in an MSP environment, you already know the truth: 👉 Repetitive tasks will slowly destroy your soul. Checking disk space Monitoring services Logging into multiple machines Fixing the same issues again and again At some point, you realize: “I’m not being paid to click the same thing 50 times.” That’s where PowerShell saves you. But… After a few “learning experiences” (a.k.a. breaking things in production 😅), I realized: 👉 Automation is powerful… but dangerous. So here are 5 PowerShell scripts every MSP should use —written in a safe, production-friendly way . 🛠️ 1. Disk Space Check (Prevent Tickets Before They Happen) This is one of the most common MSP issues. Instead of waiting for: “My computer is slow” You can detect problems early. ```powershell id="disk01" $computers = @

If you work in an MSP environment, you already know the truth:

👉 Repetitive tasks will slowly destroy your soul.

  • Checking disk space

  • Monitoring services

  • Logging into multiple machines

  • Fixing the same issues again and again

At some point, you realize:

“I’m not being paid to click the same thing 50 times.”

That’s where PowerShell saves you.

But…

After a few “learning experiences” (a.k.a. breaking things in production 😅), I realized:

👉 Automation is powerful… but dangerous.

So here are 5 PowerShell scripts every MSP should use—written in a safe, production-friendly way.

🛠️ 1. Disk Space Check (Prevent Tickets Before They Happen)

This is one of the most common MSP issues.

Instead of waiting for:

“My computer is slow”

You can detect problems early.

powershell
$computers = @("PC1","PC2","PC3")


foreach ($computer in $computers) {
 try {
 $disks = Get-CimInstance Win32_LogicalDisk -ComputerName $computer -Filter "DriveType=3"


`foreach ($disk in $disks) {
 $freePercent = [math]::Round(($disk.FreeSpace / $disk.Size) * 100, 2)

 if ($freePercent -lt 20) {
 Write-Output "$computer - Low disk space on $($disk.DeviceID): $freePercent%"
 }
 }
}
catch {
 Write-Output "Failed to check $computer"
}`


Enter fullscreen mode
 


 Exit fullscreen mode


}


`👉 **Why this matters:**
You fix issues *before* users notice.

---

# 🔄 2. Safe Restart Script (No More Accidental Chaos)

Let’s be honest…

👉 We’ve all restarted the wrong machine at least once.

Here’s a safer version:


```powershell id="restart01"
$computers = @("PC1","PC2")

foreach ($computer in $computers) {
 if (Test-Connection -ComputerName $computer -Count 1 -Quiet) {
 Restart-Computer -ComputerName $computer -WhatIf
 } else {
 Write-Output "$computer is offline"
 }
}`


Enter fullscreen mode
 


 Exit fullscreen mode


👉 Key feature: -WhatIf
This shows what would happen without actually doing it.


## 🧠 3. Service Health Check (Catch Hidden Problems)


Some services fail silently.


This script helps you detect them quickly:


```powershell id="service01"
$services = @("Spooler","W32Time")


foreach ($service in $services) {
 $status = Get-Service -Name $service


`if ($status.Status -ne "Running") {
 Write-Output "$service is NOT running"
}`


Enter fullscreen mode
 


 Exit fullscreen mode


}


`👉 **Upgrade idea:** Automatically restart failed services (carefully!)

---

# 🔐 4. Local Admin Audit (Security Must-Have)

This is huge for cybersecurity.

You should always know:

👉 **Who has admin access?**


```powershell id="admin01"
$admins = Get-LocalGroupMember -Group "Administrators"

foreach ($admin in $admins) {
 Write-Output $admin.Name
}`


Enter fullscreen mode
 


 Exit fullscreen mode


👉 Why this matters:
Unauthorized access = major security risk


## 📋 5. Script Logging (The Thing Everyone Skips 😅)


This is not optional.


Seriously.


```powershell id="log01"
Start-Transcript -Path "C:\Logs\msp_script.log"


Write-Output "Script started..."


## Your script here


Write-Output "Script completed."


Stop-Transcript


`👉 **Why this matters:**

* Debug faster
* Track actions
* Prove what happened

---

# ⚠️ The Most Important Rule

All these scripts are useful.

But the real difference is:

👉 **How you run them**

---

## 🧠 My Safety Checklist (Always Follow This)

Before running any script:

* Use `-WhatIf` whenever possible
* Test on ONE machine first
* Check permissions
* Add logging
* Assume something will fail

---

# 😂 Real Talk

PowerShell doesn’t make mistakes.

👉 **We do.**

PowerShell just executes our bad ideas… very efficiently.

---

# 🚀 Final Thought

If you use these scripts correctly:

* You save hours
* You reduce errors
* You look like a hero

If you use them incorrectly:

👉 You create a story for your next blog post 😅

---

# 👇 Your turn

* What’s your go-to PowerShell script?
* Ever automated something that went… very wrong?

Let’s share 👇`


Enter fullscreen mode
 


 Exit fullscreen mode*
Was this article helpful?

Sign in to highlight and annotate this article

AI
Ask AI about this article
Powered by Eigenvector · full article context loaded
Ready

Conversation starters

Ask anything about this article…

Daily AI Digest

Get the top 5 AI stories delivered to your inbox every morning.

Knowledge Map

Knowledge Map
TopicsEntitiesSource
PowerShell …versionproductservicefeaturesafetyDEV Communi…

Connected Articles — Knowledge Graph

This article is connected to other articles through shared AI topics and tags.

Knowledge Graph100 articles · 259 connections
Scroll to zoom · drag to pan · click to open

Discussion

Sign in to join the discussion

No comments yet — be the first to share your thoughts!

More in Products