Everyday PowerShell - the pipeline, objects, filtering, error handling, REST calls, and the Active Directory cmdlets that make up most Windows automation.
01
Pipeline & Objects
The pipeline passes objects, not text
Each cmdlet outputs .NET objects with properties/methods - the next cmdlet in the pipeline receives those objects, not printed text
Use Get-Member to see what properties and methods an object exposes
Filter left, format right - narrow the object set before formatting, since formatting for display makes objects harder to reuse
$_ is the current object in the pipeline. Select-Object picks properties (or -First/-Last N objects); Format-* is for display only - never pipe its output into another cmdlet.
Common comparison & logical operators
Operator
Meaning
-eq / -ne
Equal / not equal
-gt / -lt
Greater than / less than
-ge / -le
Greater or equal / less or equal
-like / -notlike
Wildcard match (*, ?)
-match / -notmatch
Regex match
-contains / -in
Collection contains value / value in collection
-and / -or / -not
Logical operators
Comparison operators are case-insensitive by default; prefix with c (e.g. -ceq, -clike) to force case-sensitive.
-ErrorAction Stop turns a non-terminating error into a terminating one so catch actually fires - most cmdlets don't throw by default.
02
Active Directory Module
Import the module
Import-ModuleActiveDirectory
Ships with RSAT (Remote Server Administration Tools) - install via Add-WindowsCapability -Online -Name Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0.1.0 on a client, or the AD-Domain-Services feature on a DC.
-Identity takes a SamAccountName, DN, GUID, or SID. -Filter uses PowerShell-style syntax (not LDAP) and needs -Properties to return anything beyond the default attribute set.
The Graph PowerShell SDK is the modern, supported replacement for the deprecated AzureAD / MSOnline modules. Connect-MgGraph triggers an interactive sign-in unless -Identity or a certificate/app credential is supplied.
For scheduled/unattended jobs, register an app in Entra ID, grant it application (not delegated) permissions with admin consent, and authenticate with a client certificate instead of a user login.
Az (Az.Accounts, Az.Resources, Az.Compute, …) manages Azure infrastructure - VMs, resource groups, storage. It's a separate module family from Microsoft.Graph, which manages Entra ID / Microsoft 365 identity data.