Hyper-V Cluster 迁移VM
命令说明:
Get-VM : to get the list of running VMs from the source Hyper-V host
Out-Grid : with the new -PassThru parameter – to display an interactive list of VM’s from which you can select the VM’s to Live Migrate
Move-VM : to perform the actual Live Migration
●顺序迁移VM命令:
1 Get-VM -ComputerName $HostServer | Out-GridView 2 -Title “Select one or more VMs to Live Migrate” -PassThru | 3 Move-VM -DestinationHost $Dest_Host -DestinationStoragePath (Drive Num):\ShareDisk
●并行迁移VM(powershell3.0之后)
1 Workflow Invoke-ParallelLiveMigrate 2 3 { 4 5 Param ( 6 7 [parameter(Mandatory=$true)][String[]] $VMList, 8 9 [parameter(Mandatory=$true)][String] $SourceHost, 10 11 [parameter(Mandatory=$true)][String] $DestHost, 12 13 [parameter(Mandatory=$true)][String] $DestPath 14 15 ) 16 17 ForEach -Parallel ($VM in $VMList) 18 19 { 20 21 Move-VM -ComputerName $SourceHost -Name $VM -DestinationHost $DestHost -DestinationStoragePath $DestPath 22 23 } 24 25 }
工作流-调用:
1 $VMList = Get-VM -ComputerName SOURCE_HOST | Out-GridView -Title “Select one or more VMs to Live Migrate” -PassThru Invoke-ParallelLiveMigrate -VMList $VMList.Name -SourceHost SOURCE_HOST -DestHost DEST_HOST -DestPath DRIVE:\FOLDER
在代码块中调用:
1 Invoke-Command -ComputerName $SourceHost -credential $credential -Authentication Credssp -ScriptBlock { 2 param($Shared,$SourceHost,$DestHost,$DrivePath,$VMList) 3 4 … 5 6 } -ArgumentList $Shared,$SourceHost,$DestHost,$DrivePath,$VMList
参考:
[Windows PowerShell 5.1]
https://msdn.microsoft.com/zh-cn/powershell/reference/5.1/readme
[Hyper-V Module] 命令
https://technet.microsoft.com/itpro/powershell/windows/hyper-v/index
[Powershell popup window]
http://techibee.com/powershell/how-to-get-pop-up-message-box-using-powershell/839