This will be an evolving list as I find good and simple one-liner powershell commands:
- Get-VM | Update-Tools -NoReboot
- As you can tell this one updates the vmtools on the VMs (caveat: doesn't always work with certain clients)
- Get-VM | Get-Snapshot | where {$_.Created -lt "mm/dd/yyyy"} | fl *
- Snapshots in VMware is a royal pain in the neck, this is a one liner that helps discover any snapshots older than mm/dd/yyyy
- Get-VM | Get-Snapshot | where {$_.Created -lt "mm/dd/yyyy"} | Remove-Snapshot
- Yep, the same as the last one but this one merges the snapshot into the main .vmdk
- Get-PowerCLIVersion
- It is essentially that, get the version of the PowerCLI installed and the attached snapins
- get-vm <vmname> | get-vmhost
- This shows a specific vm is on which VMhost
- foreach ($vhost in get-cluster <cluster name> | get-vmhost) {$vhost | new-datastore -Nfs -Name <nfs datastore name> -Path "< path >" -NfsHost <hostip>}
- Yep this is one line and this is from an earlier one of my posts. This one adds a datastore to all of your hosts (within a cluster)
- http://darusintegration.blogspot.com/2011/10/powershell-connect-all-hosts-to-nfs.html
- get-service | where {$_.DisplayName -match "VMware"}
- This is one of the best ones for the vCenter server, when you want to check the status of your vCenter Services.
- get-vm <named VM>| suspend-vm
- suspends the named VM **be careful running this in production without the <named VM> variable as it will suspend ALL VMs in the datacenter
- get-vmhost <VC> | get-vm | where {$_.Name -notmatch "<Guest to Exclude>"} | move-vm -destination (get-vmhost <ESX Server to move to>)
- http://darusintegration.blogspot.com/2011_04_01_archive.html Yep, this one has been seen before too. This is one of my favourite ones as I use the move-vm cmdlets very frequently.
- Get-VM <VM Name> | Set-VM -numCPU 2 -MemoryMB 4096
- Use this when you have hot-add CPU and Memory enabled and you can add it live.
- Get-VM | Select name, @{N="SyncWithHost"; E=$_.extensiondata.config.tools.synctimewithhost}
This is a one liner for NTP resync, full script at vNoob
http://www.vnoob.com/2012/05/quicktipmanage-vm-ntp-with-powercli
- Get-VM | Select Name, @{N="Cluster";E={Get-Cluster -VM $_}}, ` @{N="ESX Host";E={Get-VMHost -VM $_}}, ` @{N="Datastore";E={Get-Datastore -VM $_}}
- This one is a slick one from ICT-Freak.nl and produces wonder output of VM | Cluster | Host | Datastore
Comments