VMware PowerCLI command generator
Nobody remembers every flag on New-VM. Or New-VMHostNetworkAdapter, honestly. So tick the options here and you get PowerCLI that runs: spin up and manage vSphere VMs, grab snapshots, wire ESXi networking, fire off esxcli. Each cmdlet comes with a one-line note on what it actually does. It all happens in your browser, nothing leaves the page.
What this PowerCLI generator does
PowerCLI is the PowerShell module for driving vSphere from a terminal. It’s how you script the stuff you’d otherwise click through hundreds of times in the vSphere Client. Here’s the snag, though. A real task is almost never one cmdlet. Creating a VM means New-VM with the right host, the right datastore, disk format, guest id, network, and then usually New-CDDrive plus Start-VM on top. This thing stitches the whole sequence together from a handful of choices, so what you copy actually runs start to finish. Each cmdlet gets a plain-English note too.
It handles the four jobs I reach for most around vSphere. VM lifecycle. Snapshots. Host networking, meaning the virtual switches and port groups and VMkernel adapters. And host operations, which includes running esxcli through PowerCLI. Every script kicks off from a Connect-VIServer session, because that’s the first thing any PowerCLI script needs anyway.
Getting started with PowerCLI
Install the module once from an elevated PowerShell: Install-Module VMware.PowerCLI -Scope CurrentUser. Then connect with Connect-VIServer -Server vcenter.example.com and you’re in. If you’ve got vCenter, point at that instead of the individual hosts, so cluster features like vMotion and DRS stay on the table for your scripts. Lab box with a self-signed cert? Run Set-PowerCLIConfiguration -InvalidCertificateAction Ignore first or the connect just whines at you.
The cmdlets behind common tasks
| Task | Cmdlet |
|---|---|
| Connect | Connect-VIServer |
| Create a VM | New-VM (with -DiskGB, -MemoryGB, -NumCpu, -GuestId, -NetworkName) |
| Clone from a template | New-VM -Template |
| Snapshot | New-Snapshot, Get-Snapshot, Remove-Snapshot |
| Virtual switch and port group | New-VirtualSwitch, New-VirtualPortGroup |
| VMkernel adapter | New-VMHostNetworkAdapter |
| Run esxcli | Get-EsxCli -V2 |
esxcli through PowerCLI
Pretty much anything you’d type into the ESXi shell with esxcli, you can drive remotely instead. Get-EsxCli -VMHost host -V2 hands you back an object whose namespaces mirror the esxcli tree. So $esxcli.network.nic.list.Invoke() lists the physical NICs, and $esxcli.storage.core.adapter.rescan.Invoke() rescans storage. The win here is reaching esxcli the scriptable, credential-managed way, no SSH enabled on every single host. Which, if you’ve ever had to audit who left SSH running where, you’ll appreciate.
Privacy and how this tool runs
JavaScript builds the script right here in your browser. Your server names, VM names, datastore paths: none of it gets sent off or logged, full stop. Once the page has loaded you can even yank the network cable and it keeps working offline.
Frequently asked questions
How do I create a VM with PowerCLI?
Connect first with Connect-VIServer. Then New-VM -Name web01 -VMHost esxi01 -Datastore datastore1 -NumCpu 2 -MemoryGB 4 -DiskGB 40 -GuestId rhel9_64Guest -NetworkName "VM Network", and cap it off with Start-VM web01. The generator above just builds that whole run for you with your own values dropped in.
Should I connect PowerCLI to vCenter or to an ESXi host?
vCenter, basically always, if you’ve got one. That’s what keeps cluster features like vMotion and DRS and HA within reach, plus you can aim at any host from a single session. Going straight at an ESXi host? Save that for genuinely standalone boxes, or for the bad day when vCenter itself is down.
How do I take and remove a snapshot in PowerCLI?
To make one: New-Snapshot -VM web01 -Name pre-patch -Quiesce. To see what’s there: Get-Snapshot -VM web01. To clean it up: Get-Snapshot -VM web01 -Name pre-patch | Remove-Snapshot -Confirm:$false. Tack on -Memory if you want the live memory state captured too, though that one’s slower and I’d skip it unless you really need it.
How do I run esxcli commands from PowerCLI?
Grab the object first: $esxcli = Get-EsxCli -VMHost esxi01 -V2. Then walk the namespace, say $esxcli.network.nic.list.Invoke() or $esxcli.storage.core.adapter.rescan.Invoke(). It mirrors the esxcli tree node for node, and you never have to turn SSH on.
What GuestId should I use?
GuestId is how you tell ESXi which OS to tune itself for. It drives defaults, the SCSI controller, the NIC type, that sort of thing. Just pick the closest match: rhel9_64Guest, ubuntu64Guest, windows2019srvNext_64Guest, whatever fits. And honestly, get it wrong and the VM still boots fine, you’ll just be handed slightly worse virtual hardware than you could’ve had.
How do I ignore certificate warnings in a lab?
One line, once, before you connect: Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false. Fine for a lab. In production, please don’t, put a real trusted cert on vCenter and leave validation switched on. Ignoring cert errors in prod is exactly the kind of thing that bites you six months later.
Sources & further reading
- Broadcom Developer: VMware PowerCLI
- Broadcom TechDocs: VMware PowerCLI documentation
- Broadcom TechDocs: VMware vSphere













