Pcornel
Browse topics
Options
Recent
Favorites
Automation · Technical reference

PowerShell Automation

Direct answer

PowerShell automation uses cmdlets, pipelines of objects, functions, modules and remoting to manage Windows, Active Directory, Microsoft 365, Azure, VMware and more from scripts that run on Windows, Linux and macOS.

When to use this

Use this when automating Windows, AD, Microsoft 365, Azure or VMware with PowerShell.

First 30 seconds

1. PowerShell automates Windows (and cross-platform with PowerShell 7).

2. Object pipeline, cmdlets, remoting.

3. Use advanced functions with parameter validation.

4. $ErrorActionPreference = 'Stop' in scripts.

5. Lint and test.

Operational verification

script → cmdlets/objects → remoting → targets

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
PowerShell 7.5/current
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformPowerShell 7.5/current · Automation implementations are tool and platform specific. Use the adjacent Domain for the technology being automated and this Domain for automation behavior.
Scope / prerequisiteUse this when automating Windows, AD, Microsoft 365, Azure or VMware with PowerShell.
What next?3 suggested next steps
Child topics (this level)26
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

2 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Verification path Verify boundary

Begin with $PSVersionTable, command resolution and module identity, then verify the target-facing operation with read-back. Use Get-Command <name> -All, Get-Module, and the target API/provider query to show which implementation ran. A zero PowerShell error count or a completed pipeline is intermediate evidence; the final evidence is the intended target state observed through an independent read path. If the check only shows an intermediate PowerShell layer, continue to an independent query of the resource or service that owns the required end state.

Step 2 Where it fails Narrow the fault

Do not equate script completion with idempotency, authorization, or target convergence. Execution policy is not a security boundary; a cmdlet success record can precede eventual consistency; native exit status is separate from PowerShell errors; and a remote session can be healthy while the target application is not. Preserve engine/session identity, command source, transport/API state and target read-back as separate evidence layers. Re-run the original consumer-facing operation after remediation and keep the previous evidence for before/after comparison.

Evidence references

Evidence · 1 on this Topic

Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.

observation · 1
Drill down

Subtopics

Go one level deeper into this subject.

Subtopic PowerShell Fundamentals

PowerShell fundamentals: cmdlets output objects, the pipeline passes them on, Get-Help and Get-Member explain them, and PowerShell 7 runs cross-platform beside Windows PowerShell 5.1.

Subtopic Cmdlets

Cmdlets are PowerShell's built-in commands named Verb-Noun, such as Get-Service or Set-Item, which output objects.

Subtopic Objects

PowerShell passes .NET objects, not text, between commands, so properties can be selected, filtered and sorted directly, such as Get-Process | Where-Object CPU -gt 100.

Subtopic Pipeline

The PowerShell pipeline passes objects from one command to the next, binding them to parameters by value or property name, such as Get-ADUser -Filter * | Set-ADUser -Department IT.

Subtopic Variables

PowerShell variables start with $, hold any object type and can be strongly typed with [int] or [string].

Subtopic Functions

PowerShell functions group reusable code with a name and param() block.

Subtopic Modules

PowerShell modules package functions, cmdlets and resources (.psm1 with a .psd1 manifest), installed from the PowerShell Gallery with Install-Module and loaded with Import-Module.

Subtopic Scripts

PowerShell scripts are .ps1 files with parameters, functions and logic.

Subtopic Parameters

PowerShell parameters are declared in param() with types, Mandatory, defaults and validation such as ValidateSet or ValidatePattern, so bad input fails before the script acts.

Subtopic Advanced Functions

Advanced functions use [CmdletBinding()] and param() with validation attributes, pipeline input, -WhatIf and -Confirm support and verbose output, behaving like compiled cmdlets.

Subtopic Error Handling

PowerShell error handling distinguishes terminating and non-terminating errors.

Subtopic Try / Catch / Finally

try/catch/finally in PowerShell runs code, catches terminating errors (optionally by exception type) and always runs the finally block for cleanup, such as closing sessions.

Subtopic PowerShell Remoting

PowerShell Remoting runs commands on other computers with Invoke-Command or Enter-PSSession, over WinRM on Windows or SSH in PowerShell 7, using Kerberos for domain authentication.

Subtopic WinRM

WinRM is the Windows service behind PowerShell Remoting, listening on 5985 for HTTP and 5986 for HTTPS.

Subtopic CIM

CIM cmdlets (Get-CimInstance, Invoke-CimMethod, New-CimSession) query Windows management data over WS-Man, replacing the older WMI cmdlets and working well remotely.

Subtopic WMI

WMI is the older Windows management interface queried with Get-WmiObject in Windows PowerShell.

Subtopic Jobs

PowerShell jobs run commands in the background with Start-Job or -AsJob, checked with Get-Job and collected with Receive-Job, useful for long or parallel tasks.

Subtopic Parallel Execution

Parallel execution in PowerShell 7 uses ForEach-Object -Parallel with -ThrottleLimit, while Invoke-Command runs on many remote computers at once.

Subtopic Scheduled Jobs

PowerShell scheduled jobs (Register-ScheduledJob) or scheduled tasks (Register-ScheduledTask) run scripts on a schedule; use a service account or gMSA and log output to a file.

Subtopic Credentials

PowerShell credentials are PSCredential objects created with Get-Credential or from SecretManagement, passed to -Credential parameters.

Subtopic SecretManagement

SecretManagement is a PowerShell module that gives one interface (Get-Secret, Set-Secret) to vaults such as SecretStore, Azure Key Vault or KeePass, keeping secrets out of scripts.

Subtopic REST APIs

PowerShell calls REST APIs with Invoke-RestMethod, which converts JSON responses to objects, supports headers, bodies, authentication and, in PowerShell 7, retries with -MaximumRetryCount.

Subtopic JSON

PowerShell handles JSON with ConvertFrom-Json to turn text into objects and ConvertTo-Json -Depth to serialize, since the default depth of 2 silently truncates nested data.

Subtopic XML

PowerShell handles XML with [xml] type casting, Select-Xml with XPath, and Export-Clixml and Import-Clixml for saving objects, including encrypted credentials for the same user.

Subtopic CSV

PowerShell handles CSV with Import-Csv, which turns rows into objects with properties from the header, and Export-Csv -NoTypeInformation for reports.

Subtopic PowerShell Troubleshooting

Troubleshoot PowerShell scripts with Set-PSDebug, Write-Verbose and -Verbose, inspecting $Error[0] | Format-List * -Force, the execution policy, module versions and the PowerShell edition in use.

Key points
  • PowerShell passes objects, not text.
  • Use -WhatIf before bulk changes.
  • Set $ErrorActionPreference = 'Stop' so try/catch works.
Key checks
  • $PSVersionTable — PowerShell version/edition
  • Invoke-ScriptAnalyzer -Path . -Recurse — lint
  • Invoke-Pester — tests
ReferenceWhy it matters1 section · depth on demand

In depth

PowerShell automation uses PowerShell's object pipeline, cmdlets and modules to manage Windows, Microsoft 365, Azure, VMware and many other platforms. Because cmdlets return objects, you can filter and format data without parsing text.

AreaModules
Windows/ADActiveDirectory, GroupPolicy, DnsServer
AzureAz
Microsoft 365/EntraMicrosoft.Graph, ExchangeOnlineManagement
VMwareVCF.PowerCLI
RemotingBuilt-in WinRM and SSH remoting
Get-ADUser -Filter 'Enabled -eq $false' -SearchBase 'OU=Staff,DC=corp,DC=example,DC=com' | Select-Object Name, LastLogonDate | Export-Csv disabled.csv -NoTypeInformation

Prefer PowerShell 7 for new automation; keep Windows PowerShell 5.1 for modules that still require it.

ReferenceImportant terms & boundaries2 sections · depth on demand

Platform, version and operating-envelope scope

PowerShell 5.1/7+, module versions and remoting endpoint behavior vary by host/platform.

PowerShell mechanics

PowerShell automation is an engine-and-runspace execution model, not merely a shell script launcher. Command discovery and parameter binding select the executable command, objects move through typed success/output streams, providers expose data stores through PowerShell drives, and native processes form a separate boundary with their own exit codes. The host, PowerShell edition, loaded modules, runspace/session state and target API or transport together determine what a command actually means.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.
ReferenceConfiguration & state1 section · depth on demand

Authoring and lifecycle

Treat the script or module repository as persistent intent and the running session as derived state. Pin required module versions where reproducibility matters, declare prerequisites instead of relying on interactive profile state, separate secret acquisition from business logic, and make repeated execution safe by reading current target state before mutation. Automation that crosses remoting, REST or native-process boundaries must record those boundaries explicitly because each has different authentication, serialization and failure semantics.

Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical examples

Configuration & expected output

Concrete examples are shown only when the stored reference contains an actual configuration or output shape for this Topic.

Configuration example

PowerShell 7.5/current 7.5/currentMinimal authored PowerShell pattern for PowerShell Automation

Assumptions: Review target identity, permissions and environment before mutation.

#Requires -Version 7.2
Set-StrictMode -Version Latest
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docPowerShell 7.5/current 7.5/current

Microsoft Learn documentation reviewed for bounded PowerShell reference claims. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://learn.microsoft.com/en-us/powershell/ · confidence 94%
Technical changelog & impact

What changed and what may be affected

Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.

Related reference impactReview these references after material technical changes when their shared boundary is affected.
Embedded reference data

Quick lookup tables

PowerShell Automation · PowerShell operational reference

Topic-specific PowerShell runtime identity, persistence, verification, output and failure-boundary lookup.

BoundaryPowerShell Automation reference
Runtime identityPowerShell edition/version + command/module source
Persistent intentScript/module/config prerequisites under source control
VerificationRead-only discovery → execution evidence → independent target read-back
Output contractStructured objects/streams before formatting
Failure boundarySeparate engine/binding from transport/API/native and target-state failures
Depth when you need it

Deep reference

Healthy vs suspicious evidence

Output interpretation

Interpret PowerShell output as objects and streams before formatting. Capture object type and relevant properties, the error stream/ErrorRecord where applicable, and $LASTEXITCODE for native executables. Formatting output is presentation and should not be used as a machine-readable contract. For remote commands, remember that returned objects may be deserialized representations rather than live local instances. This makes future runs comparable even when the host changes table width, formatting views or property display order.

Confirmation

Confirm action

Continue?