Windows Server 2025 / PowerShell Basics: Objects, Pipelines, and Server Queries

PowerShell works with objects containing properties rather than only screen text. Combine query commands with Where-Object, Select-Object, and Sort-Object to inspect server information using explicit conditions.

Identify the shell and command help

These read-only examples target Windows PowerShell 5.1 on Windows Server 2025. A separately installed PowerShell 7 session can have different module compatibility. Restricted accounts may see less information even when a query does not normally require elevation.

$PSVersionTable
Get-Command Get-Service
Get-Help Get-Service -Examples

Get-Command checks availability; Get-Help explains usage and parameters. If local help is incomplete, check the official reference for the same version rather than executing a downloaded helper script. Verb-noun names also signal intent: Get and Set perform different kinds of work.

Inspect properties before processing output

A service object has a name, display name, status, and other properties. Work with those fields rather than cutting text according to displayed column positions. See PowerShell objects and their properties.

Get-Service | Select-Object -First 5
Get-Service | Get-Member
Get-Service -Name WinRM | Select-Object Name,DisplayName,Status

Get-Member distinguishes properties from methods. Methods can perform actions, so do not invoke one merely because its name looks useful. This lesson queries and filters; it does not start or stop services.

Connect conditions with a pipeline

The vertical bar passes objects from one command to the next. This pipeline selects running services, sorts by name, and returns chosen columns. $_ denotes the current object:

Get-Service |
    Where-Object { $_.Status -eq 'Running' } |
    Sort-Object Name |
    Select-Object Name,DisplayName,Status

For comparison, change only Running to Stopped, observe the different result set, then restore Running. The filter changes; actual services do not. -eq compares equality, -ne inequality, -gt greater-than, and -like patterns. Check data types when comparing numeric values rather than assuming displayed text behaves like numbers.

Use variables and explicit units

This query stores fixed-disk objects and calculates capacity and free space in gibibytes (GiB). PowerShell’s 1GB constant is 1,073,741,824 bytes; the column names show that binary unit.

$labDisks = Get-CimInstance Win32_LogicalDisk -Filter 'DriveType=3'
$labDisks | Select-Object DeviceID,
    @{Name='SizeGiB';Expression={[math]::Round($_.Size / 1GB,1)}},
    @{Name='FreeGiB';Expression={[math]::Round($_.FreeSpace / 1GB,1)}}

The variable contains disk objects, not a formatted table, and can be filtered again. Reserve Format-Table for the final human-readable display. Putting it before CSV export changes the objects into formatting data and loses the intended column structure. Values and row counts depend on the actual drives.

Keep queries and changes distinct

  1. Use Get-Command and help to identify the command and parameters.
  2. Record current values with query commands.
  3. For a change command supporting -WhatIf, inspect the proposed action.
  4. Assess operational effects and recovery separately from the preview.
  5. Keep a readable .ps1 file and record where it must run.

A missing command can mean a spelling error, absent module, or different shell version; it is not the same as access denied. Do not disable execution policy and security features together to make a script run. Follow the organization’s approved script and signing requirements.

More posts in this category
Windows Server 2025 / Server Core vs Desktop Experience: Which Should You Install?

Windows Server 2025 / Server Core vs Desktop Experience: Which Should You Install?

Compare local tools, remote management, application support, and recovery access before choosing a Windows Server 2025 installation option.

Windows Server 2025 / How to Download the Evaluation ISO and Prepare a Virtual Machine

Windows Server 2025 / How to Download the Evaluation ISO and Prepare a Virtual Machine

Get official evaluation media, check activation conditions, prepare a Hyper-V VM, and troubleshoot common installation boot problems.

Windows Server 2025 / How to Use PowerShell Remoting with WinRM

Windows Server 2025 / How to Use PowerShell Remoting with WinRM

Configure a targeted remote management path, distinguish domain and workgroup authentication, and verify where commands execute.

Windows Server 2025 / How to Install Windows Admin Center and Connect a Server

Windows Server 2025 / How to Install Windows Admin Center and Connect a Server

Plan the gateway, HTTPS certificate, and server connection, then troubleshoot browser and management paths separately.

Windows Server 2025 / How to Add and Remove Roles and Features

Windows Server 2025 / How to Add and Remove Roles and Features

Choose the correct server and components, install Windows Server Backup as a lab example, and verify configuration and removal scope.

Windows Server 2025 / How to Enable Remote Desktop and Check Firewall Access

Windows Server 2025 / How to Enable Remote Desktop and Check Firewall Access

Configure administrative RDP access with NLA, scoped firewall rules, and tests that separate network reachability from user authentication.

Windows Server 2025 / How to Plan a Virtual Lab and Network

Windows Server 2025 / How to Plan a Virtual Lab and Network

Design an isolated Windows Server 2025 lab with a consistent IP and DNS plan, practical VM resource allocations, and clear recovery records.

Windows Server 2025 / PowerShell Basics: Objects, Pipelines, and Server Queries

Windows Server 2025 / PowerShell Basics: Objects, Pipelines, and Server Queries

Inspect command help and object properties, filter services, and calculate disk values without confusing display formatting with data.

Windows Server 2025 / How to Set the Computer Name, Static IP, DNS, and Time

Windows Server 2025 / How to Set the Computer Name, Static IP, DNS, and Time

Configure initial server identity and networking while preserving console access, and choose DNS and time settings appropriate to the domain stage.

Windows Server 2025 / Server Roles and Learning Roadmap

Windows Server 2025 / Server Roles and Learning Roadmap

Understand the roles Windows Server 2025 can provide, plan a small learning environment, and follow a practical workflow from installation to verified recovery.