- This topic has 2 replies, 2 voices, and was last updated March 6, 2018 by
Ted B.
Check if a VM is in a VPG
You must be logged in to create new topics.
Click here to login
Hi all.
I’d like to check for the name of a server in Zerto and see if it’s a member of a VPG, using either the PS cmdlets or API. I see ways to list all VPGs and then list all the servers in those VPGs, which I could then check the server name against. However, that’s a fairly heavy query (and much more complicated code) if all I want to do is to check a servername.
I’ve both the Zerto Virtual Replication PowerShell Cmdlets Guide and the Automating Zerto Virtual Replication with PowerShell & REST APIs Whitepaper, but with no luck. I feel like there’s got to be an easy way to do this that I am missing. Can someone point me in the right direction for this?
This is for a server decom process, checking Zerto should be enough because we’re hopefully not decommissioning too many systems that are being replicated between DCs. Eventually, I’ll probably add a Remove VM from VPG step.
Thanks in Advance,
Ted
Ted, I created the below script for the opposite purpose – to find VMs that are not in a VPG, but you can tweak it for your needs. Note that this uses the basic VMware Powershell module and the “ZertoModule” available in the standard repository (using Find-Module), which I later realized is not provided by Zerto. I am currently in the process of converting this to use standard Zerto API calls, but I’m not there yet…
Hope this helps….
$clustervms = get-cluster $cluster | get-vm
$zertovms = get-zertovm
#initialize arrays
$protected = @()
$unprotected = @()
foreach ($vm in $clustervms) {
$vpg = $zertovms | where {$_.vmname -eq $vm.name}
if ($vpg -eq $null){ # VM is not included in Zerto Replication
if( $vm.name -notlike "Z-VRA*" -and` #exclude Zerto appliances
$vm.name -notlike "off-*") { # exclude decommissioned VMs
# Add VM name to Unprotected array
$unprotected += $vm.name
}
}
else {
# Add VPG Object (including VM name and VPG name) to Protected array
$protected += $vpg
}
}
Thanks for that info Jason. Get-ZertoVM is exactly what I needed. I just got a basic script going to query our Zerto server and give me the info.
Thanks!
Ted
PS: Thanks for your quick response and sorry for my delayed reply. I was out with the flu the 2nd half of last week. 🙁