Restore-HostVmReplication Check all VMs replicationstatus and restores them

140205

Okaay.. So i made a small script to restore VM replication (for all VMs on the host) if it’s in a failed state. And for some reasons, sometimes they are..

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Function Restore-HostVmReplication {
    [CmdletBinding()]
    param()
 
Write-Verbose "Importing Hyper-V Module"
Import-Module Hyper-V -verbose:$false
 
$VmReplicationError = Get-VMReplication | ? Health -NE "Normal"
 
    If ($VmReplicationError) {
        Write-Verbose "VM Replication error was found"
 
        Foreach ($VM in $VmReplicationError) {
            Write-Verbose "Trying to restore VM Replication on $($VM.Name)"
            Resume-VMReplication -VMName $VM.Name
 
            if (Get-VMReplication -VMName $VM.Name | Where-Object Health -EQ "Normal") {
                Write-Verbose "VM Replicationstatus was restored to Normal on $($VM.Name)"
 
            } else {
                Write-Verbose "VM Replicationstatus was not restored to Normal on $($VM.Name)"
            }
        }
 
    } else {
        Write-Verbose "VM Replication is up and running on all VMs"
        }
 
}
1
2
# Example
Restore-HostVmReplication -Verbose
This entry was posted in Hyper-V, Powershell. Bookmark the permalink.

Kommentera

E-postadressen publiceras inte. Obligatoriska fält är märkta *

*


7 − = fem

23 942 Spam Comments Blocked so far by Spam Free Wordpress

Följande HTML-taggar och attribut är tillåtna: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>