VMware PowerCLI command generator
Build the PowerCLI to create and manage vSphere VMs, take snapshots, configure ESXi networking and run esxcli — without memorising every parameter of New-VM and New-VMHostNetworkAdapter. Pick the options and copy a ready-to-run script, each cmdlet explained. Generated entirely in your browser.
What this PowerCLI generator does
VMware PowerCLI is the PowerShell module for managing vSphere from the command line, and it is how administrators script anything they would otherwise click hundreds of times in the vSphere Client. The catch is that a real task is rarely one cmdlet: creating a VM means New-VM with the right host, datastore, disk format, guest id and network, then often New-CDDrive and Start-VM. This generator assembles the whole sequence from a few choices so you copy a script that runs top to bottom, and explains what each cmdlet does.
It covers the four things you script most around vSphere: VM lifecycle, snapshots, host networking (virtual switches, port groups and VMkernel adapters) and host operations including running esxcli through PowerCLI. Every command starts from a Connect-VIServer session, which is the first thing any PowerCLI script needs.
Getting started with PowerCLI
Install the module once from an elevated PowerShell with Install-Module VMware.PowerCLI -Scope CurrentUser, then connect with Connect-VIServer -Server vcenter.example.com. Connect to vCenter rather than individual hosts when you have it, so cluster features like vMotion and DRS are available to your scripts. For lab or untrusted certificates, set Set-PowerCLIConfiguration -InvalidCertificateAction Ignore first.
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
Anything you would run in the ESXi shell with esxcli can be driven remotely through PowerCLI with Get-EsxCli -VMHost host -V2, which returns an object whose namespaces mirror the esxcli tree. For example $esxcli.network.nic.list.Invoke() lists physical NICs and $esxcli.storage.core.adapter.rescan.Invoke() rescans storage. This is the scriptable, credential-managed way to reach esxcli without SSH on every host.
Privacy and how this tool runs
The script is built by JavaScript in your browser. No server names, VM names or paths are sent anywhere or logged. You can use the generator offline once the page has loaded.
Frequently asked questions
How do I create a VM with PowerCLI?
Connect 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 finish with Start-VM web01. The generator assembles the full sequence with your values.
Should I connect PowerCLI to vCenter or to an ESXi host?
Connect to vCenter when you have it, so cluster features such as vMotion, DRS and HA are available and you can target any host. Connect directly to an ESXi host only for standalone hosts or when vCenter is down.
How do I take and remove a snapshot in PowerCLI?
Create one with New-Snapshot -VM web01 -Name pre-patch -Quiesce, list with Get-Snapshot -VM web01, and remove with Get-Snapshot -VM web01 -Name pre-patch | Remove-Snapshot -Confirm:$false. Add -Memory to capture live memory state.
How do I run esxcli commands from PowerCLI?
Use $esxcli = Get-EsxCli -VMHost esxi01 -V2 then call the namespace, for example $esxcli.network.nic.list.Invoke() or $esxcli.storage.core.adapter.rescan.Invoke(). It mirrors the esxcli tree without needing SSH.
What GuestId should I use?
GuestId tells ESXi which OS to optimise for, which sets defaults like the SCSI controller and NIC type. Pick the closest match, for example rhel9_64Guest, ubuntu64Guest or windows2019srvNext_64Guest. A wrong GuestId still boots but may use suboptimal virtual hardware.
How do I ignore certificate warnings in a lab?
Run Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false once before connecting. In production, install a trusted certificate on vCenter instead of ignoring validation.













