Top 10 PowerShell Scripts Every System Administrator Should Know

System administrators juggle countless tasks—from monitoring performance to managing users and automating backups. What if you could handle all that with just a few lines of code? PowerShell makes it possible. These scripts aren’t just time-savers—they’re game-changers.

 Introduction:

PowerShell is a powerful scripting language and command-line shell designed for system administration. Whether you’re managing Windows servers, automating tasks, or troubleshooting issues, PowerShell scripts can dramatically boost your efficiency. In this post, we’ll explore 10 essential PowerShell scripts every sysadmin should have in their toolkit—complete with use cases and examples.

1. Get System Information

Quickly gather details about the system’s OS, hardware, and user environment.

  1. Get-ComputerInfo

Use Case: Inventory management, troubleshooting, or compliance audits.

 2. List All Local Users

Identify all local user accounts on a machine.

  1. Get-LocalUser

Use Case: Security audits, user cleanup, or onboarding/offboarding processes.

 3. Monitor CPU and Memory Usage

Track system performance in real-time or log it for later analysis.

  1. Get-Process | Sort-Object CPU -Descending | Select-Object -First 10

Use Case: Performance tuning, identifying resource hogs.

 4. Automate Folder Backup

Copy files from one directory to another—ideal for scheduled backups.

  1. Copy-Item -Path "C:\Source" -Destination "D:\Backup" -Recurse

Use Case: Daily backups, disaster recovery planning.

5. Check for Open Ports

Scan for open ports to identify potential vulnerabilities.

  1. Test-NetConnection -ComputerName localhost -Port 80

Use Case: Network security audits, firewall testing.

6. Test Internet Connectivity

Verify if a machine can reach the internet or a specific domain.

  1. Test-Connection -ComputerName google.com -Count 2

Use Case: Troubleshooting network issues.

 7. List Installed Software

Get a list of all installed applications on a system.

  1. Get-WmiObject -Class Win32_Product | Select-Object Name, Version

Use Case: Software inventory, license compliance.

8. Restart a Remote Computer

Reboot a machine remotely using PowerShell Remoting.

  1. Restart-Computer -ComputerName "Server01" -Force

Use Case: Remote maintenance, patch management.

9. Clear Event Logs

Clean up old logs to free up space or reset for fresh monitoring.

  1. wevtutil cl Application

Use Case: Log management, troubleshooting prep.

10. Send Email Notifications

Automate alerts for system events or script results.

  1. Send-MailMessage -To "admin@example.com" -From "server@example.com" -Subject "Alert" -Body "Disk space low" -SmtpServer "smtp.example.com"

Use Case: Monitoring alerts, automated reporting.

Conclusion

PowerShell isn’t just a tool—it’s a superpower for system administrators. These scripts can save hours of manual work, reduce errors, and improve system reliability. Whether you’re just starting out or looking to level up your automation game, mastering these scripts is a smart move.

👉 Want more PowerShell tutorials or downloadable script packs?
Subscribe to our blog, leave a comment, or check out our other post: “PowerShell vs Python: Which One Should You Learn for Automation?”

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top