PowerCLI

PowerCLI Changelog

https://vdc-download.vmware.com/vmwb-repository/dcr-public/306e3e41-2a54-497e-8377-11a1cf36c107/76c39d63-455d-4f3a-af2a-368f3ea6647c/changelog.html

Power CLI Users Guide

https://code.vmware.com/docs/7335/powercli-11-0-0-user-s-guide

Power CLI CMDlet reference

https://code.vmware.com/docs/7336/cmdlet-reference

PowerCLI Install

Install-Module -Name VMWare.PowerCLI

Ignore self signed certs

Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false

Connect to vcenter

connect-viserver -protocol https –server SERVERNAME

Get information on VMs

Get-VM | fl | more

Get-VM | where-object {$_.PowerState –eq “PoweredOff”}

Get-VM 〈yourvm〉 | Stop-VMguest

iterate across VMs

foreach ($var in $vars){
Do something…
}

Get-vm | where-object {$_.MemoryGB –eq 4 } | select -ExpandProperty Name | out-file c:\VMs.txt
$vms = get-content c:\VMs.txt
Foreach-object ($vm in $vms) {
new-networkadapter -vm $vms -NetworkName "〈Port group name〉" -Type "VMXNET3" –startconnected
}

5 powercli cmdlets every admin should know

VMware PowerCLI example scripts