Usefull VMware PowerCLI Commands and others commands

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)}})}
  • VMware Support Bundle

vm-support -w /vmfs/volumes/datastore1/

Usage: /sbin/vm-support [-a] [-n] [-s] [-S] [-d duration_in_seconds] [-i interval] [-k] [-x] [-X wid] [-q] [-w] [-l] [-Z wid] [-r] [-R statedumper options] [-v] [-h]
 -a causes all cores to be tar'ed up - even those from previous
 runnings of this script
 -n causes no cores to be tar'ed up
 -s take performance snapshots in addition to other data
 -S take only performance snapshots
 -d <s> set performance snapshot duration to <s> seconds [default 300]
 -i <s> sleep <s> seconds between snapshots [default autodetect]
 -k gather files stats/ of each VM (vm's stats, vmware-stats*.log files)
 -x lists wids for running VMs
 -X <wid> grab debug info for a hung VM
 -q runs in quiet mode
 -w <dir> sets the working directory used for the output files
 -l print list of files being collected
 -Z <wid> suspends a VM and grabs debug info
 -r causes all vmfs3 volumes' volume headers to be tar'ed up
 -R <statedumper options> invokes statedumper utility with given options
 -v prints out vm-support version
 -h prints this usage statement

  • Export Advanced Settings
Get-VMHostAdvancedConfiguration -vmhost (get-vmhost) | findstr "NFS"
  • Connect to vSphere Server
Connect-VIServer [vSphere Hostname]
  • Remove all Snapshots
Get-VM | Get-Snapshot | fl | remove-Snapshot
  • Execution Signing
powershell Set-Executionpolicy unrestricted


powershell Set-Executionpolicy restricted
  • Deploy VMware Tools
Get-Cluster "Productie" | Get-VM | Update-Tools –NoReboot
Get-Cluster "Productie" | Get-Folder "Beheer servers" | Get-VM | Update-Tools –NoReboot
Get-Cluster "Productie" | Get-VM "BHR-SVR11" | Update-Tools –NoReboot
Get-View -ViewType VirtualMachine | select Name, @{ Name=”ToolsVersion”;Expression={$}}
  • Show Physica NIC details
esxcfg-nics -l
  • Sometimes you need exactly the correct version of tools from ESXi, maybe to package it via SCCM.. Here is the location of the ISO.




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s