Friday, March 9, 2012

PowerCLI - Get-VM and Stop-VM

$vCenter = "192.168.10.196"
$vcAcct = "administrator"
$vcPass = "xxxxx"

Connect-VIServer $vCenter -User $vcAcct -Password $vcPass

Get-VM 

Name                 PowerState Num CPUs Memory (MB)
----                 ---------- -------- -----------
w2k8_vcenter_1       PoweredOn  1        4096       
NTNX-Ctrl-VM-1-pe... PoweredOn  1        3072       
ubuntu-vmfs-0        PoweredOn  1        1024       
NTNX_vMA             PoweredOn  1        600        
ubuntu-vmfs-1        PoweredOff 1        1024       
NTNX-Ctrl-VM-2-pe... PoweredOn  1        3072       
NTNX-Ctrl-VM-3-pe... PoweredOn  1        3072   

Get-VM | Format-List -Property Name,PowerState

Name       : w2k8_vcenter_1
PowerState : PoweredOn

Name       : NTNX-Ctrl-VM-1-perses
PowerState : PoweredOn

Name       : ubuntu-vmfs-0
PowerState : PoweredOn

Name       : NTNX_vMA
PowerState : PoweredOn

Name       : ubuntu-vmfs-1
PowerState : PoweredOff

Name       : NTNX-Ctrl-VM-2-perses
PowerState : PoweredOn

Name       : NTNX-Ctrl-VM-3-perses
PowerState : PoweredOn

Also:

Get-VM | Format-Table -Property Name,PowerState,NumCpu,MemoryMB
To power off VM:

Get-VM ubuntu-vmfs-0 | Stop-VM -Confirm:$false

Name                 PowerState Num CPUs Memory (MB)
----                 ---------- -------- -----------
ubuntu-vmfs-0        PoweredOff 1        1024       

http://www.vmware.com/support/developer/PowerCLI/PowerCLI501/doc/vsph_powercli_usg501.pdf

No comments:

Post a Comment