Moving a virtual machine to another folder, host, cluster, resource pool, or datastore
To move a virtual machine to another folder, host, cluster, resource pool, or datastore, you can use the Move-VM
cmdlet. This cmdlet has the following syntax:
Move-VM [-AdvancedOption <AdvancedOption[]>] [[-Destination] <VIContainer>] [-Datastore <StorageResource>] [-DiskStorageFormat <VirtualDiskStorageFormat>] [-RunAsync] [-VM] <VirtualMachine[]> [-Server <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
In the first example, we will move the VM2
virtual machine to host 192.168.0.133
:
PowerCLI C:\> Get-VM -Name VM2 | Move-VM -Destination 192.168.0.133
The output to the preceding command is as follows:
Name PowerState Num CPUs MemoryGB ---- ---------- -------- -------- VM2 PoweredOn 1 1.000
In the second example, we will move virtual machine DNS1
to folder Infrastructure
:
PowerCLI C:\> $Folder...