Windows Server and PowerShell
Not every workload is on Linux. A company's payroll app runs on Windows Server with IIS, and its users sign in through Active Directory. When it breaks at night, you need to be as comfortable there as on web1.
The rule
On Windows, think services, PowerShell objects and CRLF line endings.
Windows Server runs workloads that are built on Microsoft's stack: Active Directory for users and machines, IIS for web apps, SQL Server, and many .NET applications. Modern servers are often installed as Server Core, with no desktop at all, so you manage them from the command line or remotely.
Services. Long-running programs are Windows services, the equivalent of systemd units. You list and control them with PowerShell:
Get-Service -Name W3SVC # IIS web service status
Restart-Service -Name W3SVC
Get-WinEvent -LogName System -MaxEvents 20 # recent system log entriesPowerShell passes objects, not text. On Linux, a pipe sends plain text and you cut columns out of it. In PowerShell each item is an object with named properties, so you sort and filter by name:
Get-Process | Sort-Object CPU -Descending | Select-Object -First 5 Name, CPUPowerShell commands follow a Verb-Noun pattern: Get-, Set-, Start-, Stop-, Restart-, New-, Remove-. PowerShell also runs on Linux and macOS today.
Line endings. Windows text files end lines with carriage return plus line feed (CRLF); Linux uses only line feed (LF). A shell script saved with CRLF on Windows fails on Linux with a confusing bad interpreter error, because the invisible \r becomes part of the command.
The shortcut
Translate from what you already know on Linux:
| Linux | Windows PowerShell |
|---|---|
systemctl restart nginx |
Restart-Service W3SVC |
ps aux |
Get-Process |
cat file.txt |
Get-Content file.txt |
tail -f app.log |
Get-Content app.log -Wait |
journalctl |
Get-WinEvent |
Check the service
Get-Service W3SVCshows StatusStopped.
The trap: parsing PowerShell output as text, the Linux way. Use the property names instead.
Drills
Answer fast — trust the rule.
Which PowerShell command restarts a Windows service?
What travels through a PowerShell pipeline?
A Bash script written on Windows fails on Linux with bad interpreter. What is the likely cause?
Which PowerShell command is closest to tail -f app.log?
Remember
- On Windows, think services, PowerShell objects and CRLF line endings.
- Shortcut: translate the Linux command into a Verb-Noun PowerShell command.
- Trap: treating PowerShell output as text, and shipping CRLF scripts to Linux.
