Question : Move more than VM to another host with same command

I found this script from here http://blogs.technet.com/b/heyscriptingguy/archive/2010/03/30/hey-scripting-guy-march-30-2010.aspx


It's working as it should. But I would like to move multiple VM in same time. So can some one assist me how I can modify that script that I could move more than VM to another host?

# Connect to the VMM server.

Get-VMMServer –ComputerName “VMMServer01.Contoso.com”

# Get the host that you want to move the virtual machine to.

$VMHost = Get-VMHost –ComputerName “VMHost01.Contoso.com”

#Get the virtual machine.

$VM = Get-VM -Name "VM01"

# Specify the path on the host.

$VMPath = $VMHost.VMPaths[0]

# Migrate the virtual machine.

Move-VM -VM $VM -VMHost $VMHost -Path $VMPath

Answer : Move more than VM to another host with same command


That'd be me making partial changes to variable names again.

Chris
1:
2:
3:
4:
5:
6:
7:
$VMHost = "VMHost01.Contoso.com"
$Path = (Get-VMHost $VMHost).VMPaths[0]

$VMServer = "VMMServer01.Contoso.com"
Get-VM -VMMServer $VMServer | Where-Object { $_.Name -Like "VM100*" } | ForEach-Object {
  Move-VM -VM $_ -VMHost $VMHost -Path $Path
}
Random Solutions  
 
programming4us programming4us