Saturday, January 14, 2012

PowerCLi Commands to move VM

:\Program Files\VMware\Infrastructure\vSphere PowerCLI> Get-ResourcePool vcloud | Get-VM | Update-Tools -NoReboot

For Storage Vmotion
Move-Vm -VM (get-VM AlWinDows* |where {$_.'PowerState' -ne "PoweredOn"}) -datastore ( Get-datastore "Atlas-NTNX-datastore4")

Get-Folder "" | get-vm | Move-Vm -Datastore -RunAsync


Get-VM “MyVM“ |Move-VM -datastore (Get-datastore “MyDatastore“)

The Move-VM Cmdlet covers a multiple of sins, lets check some out, you want VMotion:

Get-VM -Name “MyVM“ |Move-VM -Destination (Get-VMHost MyHost)

And also what you would expect, moving a VM to a new folder:

Move-VM -VM (Get-VM -Name MyVM)-Destination (Get-Folder -Name Production)

And moving a VM to a new resource pool, what a multifunctional cmdlet this is !

Move-VM -VM (Get-VM -Name MyVM)-Destination (Get-ResourcePool -Name “Important“)

Get-VM -Location Proteus-Cluster -Name *stress*
PS C:\Users\Nutanix01> Get-VM |Get-vmhost


PS C:\Users\Nutanix01> Get-VM -Location Proteus-Cluster|Get-VMHOST

Name ConnectionState PowerState Id CpuUsage CpuTotal Memory Memory
Mhz Mhz UsageMB TotalMB
---- --------------- ---------- -- -------- -------- ------- -------
172.x.x.x Connected PoweredOn ...-107 17026 31992 35702 49142
172.x.x.x Connected PoweredOn ...t-65 9238 31992 40414 49142
172.x.x.x Connected PoweredOn ...t-84 4740 31992 25492 49142
172.x.x.x Connected PoweredOn ...st-9 4552 31992 18584 49142



________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
PS C:\Users\Nutanix01> Get-VM -Location Proteus-Cluster -Name vMA_Proteus_5

Name PowerState Num CPUs Memory (MB)
---- ---------- -------- -----------
vMA_Proteus_5 PoweredOn 1 600



________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
PS C:\Users\Nutanix01> Get-VM -Location Proteus-Cluster -Name vMA_Proteus_5 |get-vmhost

Name ConnectionState PowerState Id CpuUsage CpuTotal Memory Memory
Mhz Mhz UsageMB TotalMB
---- --------------- ---------- -- -------- -------- ------- -------
172.x.x.x Connected PoweredOn ...t-84 5470 31992 25492 49142



________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
PS C:\Users\Nutanix01> Get-VM -Location Proteus-Cluster -Name vMA_Proteus_5 |Move-VM -Destination 172.x.x.x



PS C:\Users\Nutanix01> Get-VM -Location Proteus-Cluster -Name TestVMotion |Move-VM -Destination 172.x.x.x

Name PowerState Num CPUs Memory (MB)
---- ---------- -------- -----------
TestvMotion PoweredOff 1 2048



________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
PS C:\Users\Nutanix01> Get-VM -Location Proteus-Cluster -Name TestVMotion |Get-VMHost

Name ConnectionState PowerState Id CpuUsage CpuTotal Memory Memory
Mhz Mhz UsageMB TotalMB
---- --------------- ---------- -- -------- -------- ------- -------
172.16.x.x Connected PoweredOn ...-107 20462 31992 35703 49142



________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
PS C:\Users\Nutanix01> Get-VM -Location Proteus-Cluster -Name TestVMotion |Move-VM -Destination 172.y.y.y

Name PowerState Num CPUs Memory (MB)
---- ---------- -------- -----------
TestvMotion PoweredOff 1 2048



________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
PS C:\Users\Nutanix01> Get-VM -Location Proteus-Cluster -Name TestVMotion |Get-VMHost

Name ConnectionState PowerState Id CpuUsage CpuTotal Memory Memory
Mhz Mhz UsageMB TotalMB
---- --------------- ---------- -- -------- -------- ------- -------
172.y.y.y Connected PoweredOn ...t-84 4573 31992 25491 49142



S C:\Users\Nutanix01> Get-VM -Location Proteus-Cluster -Name TestVMotion |Get-Datastore

Name FreeSpaceMB CapacityMB
---- ----------- ----------
datastore0 45149 255744


________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
PS C:\Users\Nutanix01> Get-VM -Location Proteus-Cluster -Name TestVMotion |Move-VM -datastore datastore1

Name PowerState Num CPUs Memory (MB)
---- ---------- -------- -----------
TestvMotion PoweredOff 1 2048






:\Program Files\VMware\Infrastructure\vSphere PowerCLI> Get-ResourcePool vcloud | Get-VM | Update-Tools -NoReboot

No comments: