Skip to content

Instantly share code, notes, and snippets.

@mczerniawski
Created November 13, 2017 19:12
Show Gist options
  • Select an option

  • Save mczerniawski/65f8af157d6656552af9f3d753d5ebe0 to your computer and use it in GitHub Desktop.

Select an option

Save mczerniawski/65f8af157d6656552af9f3d753d5ebe0 to your computer and use it in GitHub Desktop.
$cluster = 'cluster'
$HVNodesActive = Get-ClusterNode -Cluster $cluster | where {$_.State -eq 'UP'}
$AllVMs = Get-VM -ComputerName $HVNodesActive | select Name,Path,ComputerName
#MOVE VMS where Storage IS
foreach ($hvhost in $HVNodesActive) {
foreach ($VM in ($AllVMs | where {$_.ComputerName -ne $hvhost -AND $_.Path -match $hvhost} ).Name) {
Get-ClusterGroup $VM -Cluster $cluster | Move-ClusterVirtualMachineRole -Node $hvhost -Wait 0 -ErrorAction SilentlyContinue
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment