Last active
May 14, 2018 12:17
-
-
Save mczerniawski/d7fe2d7b935ec6874639d211305b47aa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $cluster = 'cluster' | |
| $HVNodesActive = Get-ClusterNode -Cluster $cluster | where {$_.State -eq 'UP'} | |
| $AllVMs = Get-VM -ComputerName $HVNodesActive | select Name,Path,ComputerName | |
| #region Workflow declaration | |
| Workflow Invoke-ParallelLiveMigrateStorage | |
| { | |
| Param ( | |
| [parameter(Mandatory=$true)] | |
| $VMList, | |
| [parameter(Mandatory=$true)] | |
| [String] $DestinationRootFolder, | |
| [parameter(Mandatory=$true)] | |
| [String] $Cluster | |
| ) | |
| ForEach -Parallel ($VM in $VMList) { | |
| $NewPath = Join-Path -Path $DestinationRootFolder -ChildPath $VM | |
| get-clustergroup -Cluster $Cluster -Name $VM | ForEach-Object { | |
| Move-VMStorage -DestinationStoragePath $NewPath -VMName $_.Name -ComputerName $_.OwnerNode | |
| } | |
| } | |
| } | |
| #endregion | |
| #MOVE Storage where VMs are | |
| $VMList = @() | |
| foreach ($hvhost in $HVNodesActive) { | |
| $VMList += ($AllVMs | Where-Object {"$($_.Path)" -notmatch $_.ComputerName}) | |
| } | |
| foreach ($hvhost in $VMList) { | |
| $VMStorageToMigrate = $VMList | Where-Object {$_.ComputerName -match $hvhost} | |
| Invoke-ParallelLiveMigrateStorage -VMList $VMStorageToMigrate -DestinationRootFolder "c:\ClusterStorage\$hvhost\VMs" -Cluster $cluster | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment