Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#enter all VC's you need to connect too, this includes repliction clusters as we need to find the matching VM.
$virtualCenters = @('vc1','vc2')
foreach ($vc in $virtualCenters)
{
Connect-VIServer $vc #connect to the vc
}
$allVMs = Get-VM | Select-Object Name, @{N="Drives"; E={($_ | Get-HardDisk).count }}, ResourcePool
$replicas = $allVMs | Where-Object { $_.Name -like '*_replica' }
foreach ($replica in $replicas)
{
$productionName = $replica.Name.Replace("_replica", "");
$productionVM = $allVMs | Where-Object { $_.Name -eq $productionName}
$productionVM
if ($productionVM -eq $null)
{
Write-Host "$($productionName) was not found!" -BackgroundColor Red -ForegroundColor White
}
else
{
if ($productionVM.Drives -ne $replica.Drives) {
Write-Host "$($productionName) has $($productionVM.Drives) drives and replica has $($replica.Drives)" -BackgroundColor Red -ForegroundColor White
}
else {
Write-Host "$($productionName) OK!" -BackgroundColor DarkGreen -ForegroundColor White
}
}
Write-Host ""
Write-Host "---------------------"
Write-Host ""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment