Skip to content

VirtuallyThatGuy

Anything VMware , PowerCLI, PowerShell, Automation and some Windows

Menu
  • Home
  • PowerCLI
  • VMware
  • Automation
  • Windows
  • About
Menu

VMware ESXi CLI Cheat Sheet

Posted on 24 September 20229 October 2023 by VirtuallyThatGuy

These cheat sheets are to be used on the VMware platform. Some commands require PowerCLI, others can be run directly on the Photon OS.

CommandWhat it does
/etc/init.d/hostd restart
/etc/init.d/vpxa restart
Restart VMWare Management services on Host
# Check if your VM has (Change Block Tracking) enabled or not
(Get-VM -Name Server_Name).ExtensionData.Config.ChangeTrackingEnabled
(Get-VM-Name Server_Name).ExtensionData.Config.ChangeTrackingEnabled
# Find VMs where CBT (Change Block Tracking) is Enabled
Get-VM| Where-Object{$_.ExtensionData.Config.ChangeTrackingEnabled-eq $true}
Check if Change Block Tracking enabled on VM
Get-VM | Get-NetworkAdapter | Select @{N=’VM’;E={$_.Parent.Name}},@{N=’AdapterName’;E={$_.Name}},@{N=’Type’;E={$_.Type}} | Where-Object{$_.Type -eq “e1000”}Get VM NIC with E1000
Get-vm | Select Name, @{N=”IP Address”;E={@($_.guest.IPAddress[0])}}Get VM IP
Get-VM | Select Name, @{N=”Cluster”;E={Get-Cluster -VM $_}}, @{N=”ESX Host”;E={Get-VMHost -VM $_}}, @{N=”Datastore”;E={Get-Datastore -VM $_}} |sort-object DatastoreGet VM Name, cluster, ESX , Datastore – and sort by Datastore
Get-VM | Get-NetworkAdapter | Select-Object Parent,TypeQuery the nic type of all virtual machines
get-vm | foreach-object -process {get-harddisk $_} | select-object storageformat | format-listQuery the disk type of all virtual machines
Get-VM | Get-Snapshot | Where {$_.Created -lt (Get-Date).AddDays(-90)} | Select-Object VM, Name, Created, SizeMBGet snapshots older than 3 months
Get-VM | Get-Snapshot | Where {$_.Created -lt (Get-Date).AddDays(-120)} | Remove-Snapshot -Confirm:$falseGet snapshots then remove them
Get-VM | Format-Table Name, @{Label=”NumSnapshots”;Expression={(Get-Snapshot -VM $_ | Measure-Object).Count}}Count number of snapshots
get-vm |% { get-view $_.id } | select Name, @{ Name=”;ToolsVersion”;; Expression={$_.config.tools.toolsVersion}}Get Vmware tools version
get-vmhost | select Name,@{Name=”Time”;Expression={(get-view $_.ExtensionData.configManager.DateTimeSystem).QueryDateTime()}}Get time off hosts
ForEach ($VM in Get-VM ){($VM.Extensiondata.Guest.Disk | Select @{N=”Name”;E={$VM.Name}},DiskPath, @{N=”Capacity(MB)”;E={[math]::Round($_.Capacity/ 1MB)}}, @{N=”Free Space(MB)”;E={[math]::Round($_.FreeSpace / 1MB)}}, @{N=”Free Space %”;E={[math]::Round(((100* ($_.FreeSpace))/ ($_.Capacity)),0)}})}Get Vms and free disk space
Get-VMHost | Sort Name | Get-View | Select Name, @{N=”CPU”;E={$_.Hardware.CpuPkg[0].Description}}Get Host CPU info
Get-Vmhost *Lists Vmhost 
 get-vmhost -datastore Datastore_NameGet Vmhosts on particular datastore
$esxihost | Get-VMHostServiceGet Vmhosts services
$esxihost | Get-VMHostService | where {$_.key -eq “TSM-SSH”}Find $vmhosts with SSH running
$esxihost | Get-VMHostService | where {$_.key -eq “TSM-SSH”} | Start-VMHostServiceStart SSH service on $exsihost
$esxihost | Get-VMHostService | where {$_.key -eq “TSM-SSH”} | Stop-VMHostServiceStop SSH service on $esxihost
Get-VM | Get-View | Select-Object Name, @{name=”toolsVersions”; Expression={$_.config.tools.toolsversion}}Get Vmware Tools versions
$esxihost | Get-VM | Get-SnapshotGet list of snapshots on $esxihost
$esxihost | Get-VM | Get-VMGuest | format-tableGet list of Guest Operating systems on $esxihost
get-vmhost | select Name,@{Name=”Time”;Expression={(get-view $_.ExtensionData.configManager.DateTimeSystem).QueryDateTime()}}Get time on all hosts
Get Detailed VM information
 Get-VMHost | Select @{N=”Cluster”;E={Get-Cluster -VMHost $_}}, Name, @{N=”NumVM”;E={($_ | Get-VM).Count}} | Sort Cluster, NameList how many VMs are running on a Host
ForEach ($VM in Get-VM ){($VM.Extensiondata.Guest.Disk | Select @{N=”Name”;E={$VM.Name}},DiskPath, @{N=”Capacity(MB)”;E={[math]::Round($_.Capacity/ 1MB)}}, @{N=”Free Space(MB)”;E={[math]::Round($_.FreeSpace / 1MB)}}, @{N=”Free Space %”;E={[math]::Round(((100* ($_.FreeSpace))/ ($_.Capacity)),0)}})}List all VM’s and their disk sizes
Get-VMHost | Sort Name | Get-View | Select Name, @{N=”CPU”;E={$_.Hardware.CpuPkg[0].Description}}Get Host CPU details
Get-VMHost |Sort Name |Get-View |Select Name, @{N=“Type“;E={$_.Hardware.SystemInfo.Vendor+ “ “ + $_.Hardware.SystemInfo.Model}},@{N=“CPU“;E={“PROC:“ + $_.Hardware.CpuInfo.NumCpuPackages + “ CORES:“ + $_.Hardware.CpuInfo.NumCpuCores + “ MHZ: “ + [math]::round($_.Hardware.CpuInfo.Hz / 1000000, 0)}},@{N=“MEM“;E={“” + [math]::round($_.Hardware.MemorySize / 1GB, 0) + “ GB“}} Get Host Hardware information
Get-VMHost | Get-VMHostNetwork | Select Hostname, VMKernelGateway -ExpandProperty VirtualNic | Where {$_.ManagementTrafficEnabled} | Select Hostname, PortGroupName, IP, SubnetMaskThis will then dump the ESXi Hostnames, IPs and Subnets – For the Management Network
Get-VMHost | Get-VMHostNetwork | Select Hostname, VMKernelGateway -ExpandProperty VirtualNic | Where {$_.vMotionEnabled} | Select Hostname, PortGroupName, IP, SubnetMaskThis will then dump the ESXi Hostnames, IPs and Subnets – For the vMotion Network
Get-VMHost | Get-Cluster | Select Name, DrsEnabled, DrsMode, DrsAutomationLevelDump DRS status
Get-VMHost | Get-Cluster | Select Name, VMSwapfilePolicyDump VMSwapfilePolilcy
Get-VMHost | Get-Cluster | Select Name, HAAdmissionControlEnabledCheck status of HA Admission Control
Get-VMHost | Get-Cluster | Select Name, HAFailoverLevel, HARestartPriority, HAIsolationResponseCheck HA Status Levels
Get-VMHost | Get-VMHostNetwork | Select Hostname, VMKernelGateway -ExpandProperty VirtualNic | Select Hostname, PortGroupName, IP, MTUCheck for MTU Mismatches
Get-VirtualSwitch | Select VMHost, Name, MTUShows what the MTU settings on the Virtual Switches are
Get-VMGuestNetworkInterface –VM VMNAME | Select VM, IP, SubnetMask, DefaultGateway, DnsDumps a hosts Name, IP, Subnet, Gateway and DNS configuration 
Get-VMHost | Get-ScsiLun | Select VMHost, ConsoleDeviceName, Vendor, MultipathPolicyThis will dump the Multipath Policy of the storage on the systems to determine what the MP configuration is. 
Get-VMHost | Sort Name | Select Name, @{N=”NTP”;E={Get-VMHostNtpServer $_}}This will dump NTP Configuration settings
Get-View -ViewType HostSystem | Sort Name | Select Name,@{N=”BIOS version”;E={$_.Hardware.BiosInfo.BiosVersion}}, @{N=”BIOS date”;E={$_.Hardware.BiosInfo.releaseDate}}This will dump the hosts BIOS version and date(s)
get-vmhost | Get-VMHostAdvancedConfiguration -Name Syslog.global.logHostDump the current SYSLOG Configuration
 $esxihost | Get-VM | Get-NetworkAdapter | Select @{N=’VM’;E={$_.Parent.Name}},@{N=’AdapterName’;E={$_.Name}},@{N=’Type’;E={$_.Type}} | Where-Object{$_.Type -eq “e1000”}Detailed E1000 details of $esxihost
Get-VIEvent -maxsamples 10000 |where {$_.Gettype().Name-eq “VmCreatedEvent” -or $_.Gettype().Name-eq “VmBeingClonedEvent” -or $_.Gettype().Name-eq “VmBeingDeployedEvent”} |Sort CreatedTime -Descending |Select CreatedTime, UserName,FullformattedMessage -First 10Find Vm’s Created last 10 days
$esxihost | Get-VM | Get-Snapshot | Select VM,Name,Created,sizegb,descriptionGet Snapshot details of $esxihost and list name, vmname, sizegb and snapshot description
$myvm | Get-NetworkAdapter | Select parent, name, type, networkname, connectionstate |Format-Table -AutoSizeDefine $myvms – lists network adapter details

2 thoughts on “VMware ESXi CLI Cheat Sheet”

  1. Allen says:
    16 August 2023 at 20:46

    Thanks so much for sharing this.
    There are few commands that have invalid characters.
    Example:
    Get-VMHost | Sort Name | Select Name, @{N=”NTP”;E={Get-VMHostNtpServer $_}}

    It should probably look more like this:
    Get-VMHost | Sort Name | Select Name, @{N=’NTP’ ; E={Get-VMHostNtpServer $_}}

    Reply
  2. VirtuallyThatGuy says:
    9 October 2023 at 15:11

    yeah this fixed now

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

When autocomplete results are available use up and down arrows to review and enter to go to the desired page. Touch device users, explore by touch or with swipe gestures.

Recent Posts

  • vROps: Management Pack Troubleshooting
  • Migrate VSS Config to Another Host Using Powercli
  • Windows AD {Active Directory} (PowerShell) samples
  • Migrate VMs Between vCentres Using Powershell or PowerCLI
  • Set VM Tools to Update Automatically on VM Reboot using powershell

Recent Comments

  • JB on Script: How to get VM with Tag Assignment and export results to csv using PowerCLI or Powershell
  • DL on How to change VCSA root password and bypass BAD PASSWORD: it is based on a dictionary word for vCenter VCSA root account warning
  • 360coolp on How to change VCSA root password and bypass BAD PASSWORD: it is based on a dictionary word for vCenter VCSA root account warning
  • Yogesh on ESXi 8.x, 7.x, 6.x Service sfcbd-watchdog Not Running / Fails to Start – VirtuallyThatGuy
  • VirtuallyThatGuy on ESXi 8.x, 7.x, 6.x Service sfcbd-watchdog Not Running / Fails to Start – VirtuallyThatGuy

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • July 2019
  • May 2019
  • April 2019
  • March 2019
  • February 2019
  • January 2019
  • December 2018
  • November 2018
  • October 2018
  • July 2018
  • June 2018
  • May 2018
  • April 2018
  • March 2018
  • February 2018
  • January 2018
  • December 2017

Categories

  • Automation
  • PowerCLI
  • VMware
  • Windows
© 2025 VirtuallyThatGuy | Powered by Superbs Personal Blog theme