Hi everyone,
I have the following script to monitor Hyper-V replica on multiple clusters from same domain:
function get_info{
#Add some Styles to the Table
$head = ’
BODY{
font-family:Arial;
font-size: 12px;
background-color:#FFFFFF;
}
TABLE{
border-width: 1px;
border-style: solid;
border-collapse: collapse;
}
TH{
border-width: 1px;
border-color: #0070A8;
background-color: #006699;
color: #FFFFFF;
font-size: 15px;
}
TD{
border-width: 1px;
border-style: solid;
border-color: #0070A8;
color: #00496B;
}
’
#Get Hyper-V Replica Status
$replica_body = Get-VM –ComputerName (Get-ClusterNode –Cluster pcaxxclus204) | Where-Object { $.Name -like ‘FS’ } | Get-VMReplication |
Select Name, State, Health, PrimaryServer
$replica_body = Get-VM –ComputerName (Get-ClusterNode –Cluster pcxclus203) | Where-Object { $.Name -like ‘FS’ } | Get-VMReplication|
Select Name, State, Health, PrimaryServer |
ConvertTo-Html -Fragment -PreContent “Hyper-V Replica Status”
The script displays a table with the status of hyper-v replica of servers from clusters containing FS in the name.
My issue is that I am not able to display the status of servers which does not have replica enabled. How can I convert the text into a simple message in table ‘replication is not enabled’
Get-VMReplication : Replication is not enabled for virtual machine with name PCxxFS21.
At C:\Users\a\script2.PS1:53 char:128
- … ike ‘FS’ } | Get-VMReplication|
-
~~~~~~~~~~~~~~~~~
- CategoryInfo : ObjectNotFound: (PCxxFS21:String) [Get-VMReplication], VirtualizationOperationFailedException
- FullyQualifiedErrorId : ObjectNotFound,Microsoft.HyperV.PowerShell.Commands.GetVMReplicationCommand
Can someone please help me with this?
Thank you a lot!