This PowerShell script automates synchronization between Windows Server Failover Cluster (WSFC) node ownership and Zerto Virtual Protection Groups (VPGs).
When WSFC ownership changes, the script automatically:
- Resumes replication for the active node’s VPG
- Pauses replication for the standby node’s VPG
- Ensures only the current WSFC owner continues replication to maintain CBT consistency
It supports two detection modes: Disk-based and Group-based ownership detection.
- WSFC Node1 owns the shared disk or owns the cluster group.
- VPG Node1 is Active (replicating).
- VPG Node2 is Paused.
- ZVM Prod and ZVM DR maintain CBT replication across sites.
- Ownership of the WSFC shared disk transfers to Node2.
- The script detects the ownership change.
- VPG Node2 is resumed; VPG Node1 is paused.
- Zerto continues replication with no data collision.
- ✅ Disk-based and Group-based WSFC ownership detection
- ✅ Automatic VPG resume/pause alignment
- ✅ Detailed timestamped logging (
C:\Temp\PwshCompat) - ✅ Compatible with PowerShell 5.1+ and PowerShell 7
- ✅ Safe retry and graceful error handling
All configuration is centralized at the top of the script:
# --- HARD-CODED CONFIG ---
$ZvmHost = '192.168.222.20'
$ZvmUser = 'admin'
$ZvmPassPlain = 'password'
$NodeUser = '.\wsfcadm'
$NodePassPlain = 'password'
$ClusterFqdn = 'TOR-HV01.lab.local'
$WSFCGroupName = 'Cluster Group'
$Node1 = 'TOR-HV01-N1'
$Node2 = 'TOR-HV01-N2'
# OWNERSHIP DETECTION MODE
# 'Disk' => determine active owner by shared disk ownership (preferred)
# 'Group' => determine active owner by Cluster Group ownership (legacy behavior)
$OwnershipSource = 'Disk'
# DISK MONITORING CONFIGURATION (used when OwnershipSource = 'Disk')
$SharedDiskUniqueId = '6589CFC000000307DC30980C15CE8818'
$SharedDiskLabel = 'WSFCData1'
$DiskResourceName = 'Cluster Disk 1'
# Zerto VPG names
$VpgName1 = 'Node1'
$VpgName2 = 'node2'In this mode, the script determines the active WSFC node by checking:
- The Physical Disk Resource Owner in the cluster (
Get-CimInstance root\MSCluster). - If unavailable, it checks which node has the disk Online and Read/Write.
This is the most reliable method for shared-disk clusters.
In this mode, the script determines ownership by checking the Cluster Group owner instead of a shared disk.
Useful when the cluster has no shared disks (e.g., cluster-only workloads).
$OwnershipSource = 'Group'Logs are created under:
C:\Temp\PwshCompat\cluster-monitor-YYYYMMDD-HHMMSS.log
Each log line includes timestamp, component, and log level (DEBUG, INFO, WARN, ERROR).
- Loads FailoverClusters and Zerto.ZvmLinux.Commandlets modules.
- Connects to the ZVM using the provided credentials.
- Retrieves both VPGs and their current states.
- Determines the active WSFC owner (via disk or group).
- Resumes or pauses VPGs to match ownership.
- Logs all actions with timestamps.
Run from a system with network access to both WSFC nodes and ZVM:
.\WSFC-Zerto-Monitor.ps1Administrator privileges are recommended.
The script should run on a scheduled basis (i.e. every minute)
This script is provided as an example only and is not supported under any Zerto support program or service.
The author and Zerto disclaim all implied warranties, including merchantability and fitness for a particular purpose.
In no event shall Zerto or the author be liable for damages arising from the use or inability to use this script.
Use at your own risk.
Author: Kosta Mushkin
Company: Zerto (HPE)
Version: 1.0
Date: October 2025

