Anteckning
Åtkomst till den här sidan kräver auktorisering. Du kan prova att logga in eller ändra kataloger.
Åtkomst till den här sidan kräver auktorisering. Du kan prova att ändra kataloger.
Just wanted to share this script I wrote. The idea is I want to do something (anything) to a host and feel it might cause a service interruption so I would prefer to move all VMs off the node. Rather than doing it manually in the cluster or in VMM, or forcing VMs off in a reboot, this script will get a list of all VMs on a node and use intelligent placement to fail over VMs to the best possible node in your cluster in one quick operation. This should work for VMs running on either Hyper-V or VMWare as long as you have SCVMM managing your environments.
1: # ------------------------------------------------------------------------------
2: # EVACUATE!
3: # ------------------------------------------------------------------------------
4: # blogs.technet.com/offcampus
5: # version 1.0
6: #
7: # Description
8: # Useful for quickly moving all VMs off a host using intelligent placement.
9: #
10: # ------------------------------------------------------------------------------
11:
12: $vmhost=get-vmhost
13: write-host "Hosts:" -foregroundcolor "green"
14: foreach ($hostname in $vmhost){write-host $hostname.computername -foregroundcolor "green"}
15: write-host ""
16:
17: $Name = Read-Host "Which host would you like to evacuate?"
18:
19: $VMMServer = get-vmmserver -computername "v-scvmm-01.usedu.int"
20: $VMArray = get-vm -vmhost $Name | where {$_.customproperties -notcontains "Local"}
21: @( ForEach ($VM in $VMArray) {
22: $VMHostRating = get-vmhostrating -vm $VM -vmhostgroup "All Hosts" -ismigration | sort -property rating -descending
23: move-vm -vm $VM -vmhost $VMHostRating[0].name -RunAsynchronously
24: })