-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathGet-ReplicaStatus.ps1
More file actions
50 lines (47 loc) · 1.56 KB
/
Get-ReplicaStatus.ps1
File metadata and controls
50 lines (47 loc) · 1.56 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<#
.Synopsis
Get the Hyper-V replica status of a Hyper-V server.
.DESCRIPTION
Long description
.NOTES
Created by: Jason Wasser
Modified: 3/2/2015 02:37:31 PM
From: http://blogs.technet.com/b/enterprise_admin/archive/2013/12/17/hyper-v-replica-basic-monitoring-report.aspx
.EXAMPLE
Get-ReplicaStatus
Reports the Hyper-V Replica status from the local machine.
.EXAMPLE
Get-ReplicaStatus -ComputerName SERVER01
Reports the Hyper-V Replica status from SERVER01.
.EXAMPLE
Get-ReplicaStatus -ComputerName (Get-Content c:\temp\serverlist.txt)
Reports the Hyper-V Replica status from a list of computers in c:\temp\serverlist.txt.
#>
#Requires -Modules Hyper-V
function Get-ReplicaStatus
{
[CmdletBinding()]
[OutputType([int])]
Param
(
# ComputerName
[Parameter(Mandatory=$false,
ValueFromPipelineByPropertyName=$true,
Position=0)]
[string[]]$ComputerName=$env:COMPUTERNAME
)
Begin
{
}
Process
{
foreach ($Computer in $ComputerName) {
Write-Verbose "Checking $Computer"
$VMs = Get-VM -ComputerName $Computer | Where-Object {$_.replicationstate -notmatch "Disabled"} | Get-VMReplication
$VMs | Select-Object -Property Name, PrimaryServer, ReplicaServer, ReplicationMode, State, ReplicationHealth, @{Expression={"{0:0.0}" -f ($_.FrequencySec / 60)};Label="Target Freq (min)"}, @{Expression={"{0:N0}" -f ((get-date)-($_.lastreplicationtime)).TotalMinutes};Label="Delta (min)"}
}
}
End
{
}
}