Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Operating System  ›  Capstone Project

Windows Server and PowerShell

Windows 12 minWindows Server runs Microsoft-stack workloads as services managed with PowerShell, whose Verb-Noun commands pass objects rather than text, and whose CRLF line endings differ from Linux.

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 entries

PowerShell 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, CPU

PowerShell 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
The payroll site is downStep 1 of 4
  1. Check the service

    Get-Service W3SVC shows Status Stopped.

The trap: parsing PowerShell output as text, the Linux way. Use the property names instead.

Drills

Answer fast — trust the rule.

quick drill

Which PowerShell command restarts a Windows service?

quick drill

What travels through a PowerShell pipeline?

quick drill

A Bash script written on Windows fails on Linux with bad interpreter. What is the likely cause?

quick drill

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.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainA night on Windows

The company's IIS site is down on a Windows Server Core machine. Explain the PowerShell steps you would take to find and fix the problem, and one difference from doing the same on Linux.