Pcornel
Virtualization · Automation

PowerShell

Cheat sheet · https://pcornel.dk/topic.php?topic=3689

Back to the Topic

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.

Remember

  • Use -WhatIf before bulk changes.
  • Objects, not text — filter by properties.
  • PowerCLI needs Connect-VIServer per session.

First checks

  • Get-VM | ft Name,State,CPUUsage,MemoryAssigned — Hyper-V module
  • Connect-VIServer <vc>; Get-VM — PowerCLI
  • Invoke-Command -ComputerName <host> { Get-VM } — remote

Verify in this order

script → module → host/vCenter

Where it usually breaks

First mismatch in management intent → host/cluster capability → hypervisor runtime/task → virtual resource/device → guest state → workload-visible read-back; preserve identity/native error/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=3689

Confirmation

Confirm action

Continue?