Let’s be honest: logging into a Windows EC2 instance feels a bit like being dropped into an unfamiliar cockpit. You’ve got a mouse, a GUI, and a vague sense that maybe clicking around will fix things. But what if I told you you can manage your Windows Server from the CLI? PowerShell to the rescue! ✨
Here’s an introduction to get you started on Windows Server management using PowerShell.
1. Know where you are
You just launched an EC2 instance. Great. But where are you?
Get-ComputerInfo | Select-Object CsName, WindowsProductName, WindowsCurrentVersion
That one-liner tells you the hostname, Windows edition, and version. Handy when you’re logged into multiple servers and can’t tell them apart.
2. Services: Restart a service Without RDP
Instead of clicking through services.msc, try this:
Get-Service -Name wuauserv | Restart-Service
Boom. You just restarted the Windows Update service. Want to check a bunch of services?
"wuauserv","bits","WinRM" | ForEach-Object { Get-Service $_ }
Efficient and smugly satisfying.
3. Windows Updates: Manual but Scripted
Windows Update isn’t exactly PowerShell’s best friend by default—but you’ve got options. Either use UsoClient (bare-bones) or, better, install PSWindowsUpdate:
Install-Module -Name PSWindowsUpdate
Get-WindowsUpdate -AcceptAll -Install -AutoReboot
If you’re using SSM, you can even send this to multiple machines at once (more on that in future posts đź‘€).
4. Events: Stop Scrolling, Start Filtering
Checking Event Viewer manually? Use this instead:
Get-EventLog -LogName System -EntryType Error -Newest 10
Or hunt for trouble with precision:
Get-WinEvent -LogName Application | Where-Object { $_.Message -like "*SQL*" }
Yes, you’re now officially better than Event Viewer.
5. Disk Space: Find the culprits 🔍
Running out of space on C:\ again?
Get-PSDrive -PSProvider 'FileSystem'
Want to know what’s eating it?
Get-ChildItem -Path C:\ -Recurse | Sort-Object Length -Descending | Select-Object FullName, Length -First 10
Top 10 offenders, identified. Delete responsibly.
🛠️ How to Run These Commands with Ohlala Operations for Amazon EC2
You don’t need to open RDP, fumble with remote access, or worry about WinRM configuration. With Ohlala Operations for Amazon EC2, you can run all these commands directly from the web interface.
Click your server from the Ohlala Operations for Amazon EC2 main page and choose the Diagnostics tools menu.
In the Custom PowerShell script window, you can write the PowerShell command line you want and click Run:
Final Thought: PowerShell Is Your Co-Pilot
Your EC2 Windows instance isn’t that weird once you unlock PowerShell. Instead of clicking around in a GUI jungle, you can glide through admin tasks with elegance—and maybe even get home on time.