Pcornel
Browse topics
Options
Recent
Favorites
Virtualization · Technical reference

PowerShell

Direct answer

PowerShell automates Hyper-V with the Hyper-V module (New-VM, Set-VMProcessor, Checkpoint-VM) and vSphere with VMware PowerCLI (Connect-VIServer, New-VM, Get-Stat), covering bulk provisioning, reporting and changes.

When to use this

Use this when automating Hyper-V or vSphere with PowerShell or PowerCLI for provisioning, reporting or bulk changes.

First 30 seconds

1. PowerShell manages Hyper-V (Hyper-V module) and vSphere (PowerCLI).

2. Use remoting for many hosts.

3. Pipelines for bulk changes — test with -WhatIf.

4. Store credentials securely.

5. Log changes.

Operational verification

script → module → host/vCenter

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
virtualization
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.

Platformvirtualization
Key commandGet-Module Hyper-V -ListAvailable
Scope / prerequisiteUse this when automating Hyper-V or vSphere with PowerShell or PowerCLI for provisioning, reporting or bulk changes.
What next?3 suggested next steps
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 Checks Verify boundary
Get-Module Hyper-V -ListAvailable
Invoke-Command -ComputerName hv01 { Get-VM }

Run against several hosts with remoting; use -ErrorAction Stop and try/catch.

Step 2 Common mistakes Narrow the fault
  • Running scripts locally only; use remoting for many hosts.
  • No -ErrorAction Stop, so failures continue silently.
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
Key points
  • Use -WhatIf before bulk changes.
  • Objects, not text — filter by properties.
  • PowerCLI needs Connect-VIServer per session.
Key checks
  • Get-VM | ft Name,State,CPUUsage,MemoryAssigned — Hyper-V module
  • Connect-VIServer <vc>; Get-VM — PowerCLI
  • Invoke-Command -ComputerName <host> { Get-VM } — remote
ReferenceWhy it matters1 section · depth on demand

Remoting at scale

Invoke-Command -ComputerName hv01,hv02 -ScriptBlock { Get-VM | Where State -eq Running | Select Name,Uptime }

Documented example, not captured output.

ReferenceImportant terms & boundaries2 sections · depth on demand

In depth

PowerShell for virtualization: Hyper-V module, Failover Clustering module, VMware PowerCLI (VCF.PowerCLI / VMware.PowerCLI).

# Hyper-V: report VMs with checkpoints older than 3 days
Get-VM -ComputerName hv01,hv02 | Get-VMSnapshot | ? CreationTime -lt (Get-Date).AddDays(-3) | Select VMName,Name,CreationTime
# PowerCLI: VMs with CPU ready > 5 % in last day
Connect-VIServer vcenter01
Get-VM | ForEach-Object { $r = Get-Stat -Entity $_ -Stat cpu.ready.summation -Start (Get-Date).AddDays(-1) -IntervalMins 30 | Measure-Object Value -Average; [pscustomobject]@{VM=$_.Name; ReadyPct=[math]::Round($r.Average/(1800*1000)*100/$_.NumCpu,1)} } | ? ReadyPct -gt 5

Examples

New-VM -Name vm01 -Generation 2 -MemoryStartupBytes 4GB -NewVHDPath D:\VMs\vm01.vhdx -NewVHDSizeBytes 60GB -SwitchName External
Set-VMProcessor vm01 -Count 2
Checkpoint-VM vm01 -SnapshotName pre-patch
Get-VM | Where State -eq Running

Documented example, not captured output.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
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 docvirtualization current

Authoritative/upstream documentation reviewed for bounded claims in Automation → PowerShell. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://libvirt.org/html/index.html · confidence 94%
Confirmation

Confirm action

Continue?