{"id":509956,"date":"2025-08-18T14:16:00","date_gmt":"2025-08-18T14:16:00","guid":{"rendered":"https:\/\/www.ninjaone.com\/?post_type=script_hub&#038;p=509956"},"modified":"2025-08-18T14:17:35","modified_gmt":"2025-08-18T14:17:35","slug":"supervision-de-la-replicacion-en-hyper-v","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/es\/script-hub\/supervision-de-la-replicacion-en-hyper-v\/","title":{"rendered":"Optimiza tu gesti\u00f3n de TI: supervisi\u00f3n de la replicaci\u00f3n en Hyper-V con PowerShell"},"content":{"rendered":"<h2>Principales conclusiones<\/h2>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\"><strong>Supervisi\u00f3n automatizada de la replicaci\u00f3n de Hyper-V<\/strong>: el script automatiza el proceso de monitorizaci\u00f3n del estado de replicaci\u00f3n de Hyper-V, mejorando la eficiencia en la gesti\u00f3n del entorno virtual.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"2\" data-aria-level=\"1\"><strong>Umbrales de alerta personalizables<\/strong>: los administradores pueden establecer umbrales personalizados para las alertas de replicaci\u00f3n utilizando par\u00e1metros como <strong>-FailedFor<\/strong>.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\"><strong>Se requieren permisos elevados<\/strong>: la ejecuci\u00f3n del script requiere privilegios de administrador para acceder a la informaci\u00f3n detallada de replicaci\u00f3n de las m\u00e1quinas virtuales.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"4\" data-aria-level=\"1\"><strong>Personalizaci\u00f3n espec\u00edfica del entorno<\/strong>: utiliza variables de entorno y campos personalizados para adaptar la funcionalidad del script a entornos inform\u00e1ticos espec\u00edficos.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"5\" data-aria-level=\"1\"><strong>Herramienta de gesti\u00f3n proactiva de TI<\/strong>: el script sirve como herramienta proactiva para los profesionales de TI, garantizando la identificaci\u00f3n y resoluci\u00f3n oportunas de los problemas de replicaci\u00f3n.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"6\" data-aria-level=\"1\"><strong>Mejora con respecto a los m\u00e9todos manuales<\/strong>: ofrece un enfoque m\u00e1s completo y automatizado en comparaci\u00f3n con las comprobaciones manuales o los scripts b\u00e1sicos.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"7\" data-aria-level=\"1\"><strong>Parte integrante de la <a href=\"https:\/\/www.ninjaone.com\/es\/enterprise-it-management\/infraestructura\/\">gesti\u00f3n de infraestructuras inform\u00e1ticas<\/a><\/strong>: cuando se integra con plataformas como NinjaOne, el script a\u00f1ade un valor significativo a la gesti\u00f3n y la seguridad de la infraestructura de TI.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"8\" data-aria-level=\"1\"><strong>Requiere <a href=\"https:\/\/www.ninjaone.com\/script-hub\/updating-powershell-to-5-1\/\">PowerShell 5.1<\/a> o versiones posteriores<\/strong>: garantiza la compatibilidad y funcionalidad con la versi\u00f3n adecuada de PowerShell.<\/li>\n<\/ul>\n<p>La gesti\u00f3n eficaz de los entornos virtuales es crucial para los profesionales de TI, ya que garantiza un rendimiento y una seguridad \u00f3ptimos. Un aspecto clave es la supervisi\u00f3n y gesti\u00f3n de la replicaci\u00f3n de <a href=\"https:\/\/www.ninjaone.com\/es\/blog\/hyper-v-caracteristicas-y-capacidades\/\">Hyper-V<\/a>, una funci\u00f3n muy utilizada en redes virtualizadas con fines de redundancia y conmutaci\u00f3n por error. La supervisi\u00f3n eficaz del estado de replicaci\u00f3n de Hyper-V garantiza la continuidad de la actividad y la integridad de los datos en caso de fallos inesperados.<\/p>\n<h2>Contexto<\/h2>\n<p>La replicaci\u00f3n de Hyper-V es un mecanismo que permite a <a href=\"https:\/\/www.ninjaone.com\/es\/supervision-gestion-de-endpoints\/supervision-gestion-de-maquina-virtual\/\">las m\u00e1quinas virtuales (VM)<\/a> replicarse de un host Hyper-V a otro, proporcionando una soluci\u00f3n crucial de recuperaci\u00f3n ante desastres. Los profesionales de TI y los <a href=\"https:\/\/www.ninjaone.com\/es\/que-es-un-msp\/\">proveedores de servicios gestionados (MSP)<\/a> necesitan herramientas s\u00f3lidas para supervisar este proceso de replicaci\u00f3n. El script que estamos analizando sirve exactamente para este prop\u00f3sito, permitiendo a los administradores realizar un seguimiento eficiente del estado de las r\u00e9plicas de m\u00e1quinas virtuales y reaccionar r\u00e1pidamente ante cualquier anomal\u00eda.<\/p>\n<h2>El script:<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\">#Requires -Version 5.1\r\n\r\n&lt;#\r\n.SYNOPSIS\r\n    This will get information about the current status of Hyper-V Replication. If its abnormal it'll check the last replication time to see if it should alert on it.\r\n.DESCRIPTION\r\n    This will get information about the current status of Hyper-V Replication. If its abnormal it'll check the last replication time to see if it should alert on it.\r\n.EXAMPLE \r\n    (No Parameters)\r\n    Replication is currently failing!\r\n    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorExcep \r\n   tion\r\n    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorExceptio \r\n   n,customscript_gen_2.ps1\r\n \r\n\r\n    VMName      PrimaryServer            State   Health LastReplicationTime \r\n    ------      -------------            -----   ------ ------------------- \r\n    WIN10-TEST  SRV16-TEST.test.lan      Error Critical 4\/13\/2023 8:20:11 AM\r\n    Win10-TEST2 SRV16-TEST.test.lan      Error Critical 4\/13\/2023 8:20:11 AM\r\n\r\nPARAMETER: -FailedFor \"30\"\r\n    Time in minutes any given vm replication is allowed to be abnormal.\r\n    Ex. \"20\" will alert on a vm replication after its been in the abnormal state for 20 minutes.\r\n.EXAMPLE\r\n    -FailedFor \"20\"\r\n    WARNING: Some of the vm's currently have replication paused!\r\n \r\n\r\n    VMName      PrimaryServer                  State  Health LastReplicationTime \r\n    ------      -------------                  -----  ------ ------------------- \r\n    WIN10-TEST  SRV16-TEST.test.lan      Replicating  Normal 4\/13\/2023 8:40:04 AM\r\n    Win10-TEST2 SRV16-TEST.test.lan        Suspended Warning 4\/13\/2023 8:32:06 AM\r\n\r\nPARAMETER: -IncludePaused\r\n    Script will consider paused vm's abnormal if this parameter is used.    \r\n.EXAMPLE\r\n    -IncludePaused\r\n    Replication is currently failing!\r\n    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorExcep \r\n   tion\r\n    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorExceptio \r\n   n,customscript_gen_2.ps1\r\n \r\n\r\n    VMName      PrimaryServer                  State  Health LastReplicationTime \r\n    ------      -------------                  -----  ------ ------------------- \r\n    WIN10-TEST  SRV16-TEST.test.lan      Replicating  Normal 4\/13\/2023 8:40:04 AM\r\n    Win10-TEST2 SRV16-TEST.test.lan        Suspended Warning 4\/13\/2023 8:32:06 AM\r\n\r\nPARAMETER: -FromCustomField \"ReplaceMeWithAnyIntegerCustomField\"\r\n    Name of an integer custom field that contains your desired FailedFor threshold.\r\n    ex. \"ReplicationAlertThreshold\" where you have entered in your desired alert limit in the \"ReplicationAlertThreshold\" custom field rather than in a parameter.\r\n.EXAMPLE\r\n    -FromCustomField \"ReplaceMeWithAnyIntegerCustomField\"\r\n    WARNING: Some of the vm's currently have replication paused!\r\n \r\n\r\n    VMName      PrimaryServer                  State  Health LastReplicationTime \r\n    ------      -------------                  -----  ------ ------------------- \r\n    WIN10-TEST  SRV16-TEST.test.lan      Replicating  Normal 4\/13\/2023 8:40:04 AM\r\n    Win10-TEST2 SRV16-TEST.test.lan        Suspended Warning 4\/13\/2023 8:32:06 AM\r\n.OUTPUTS\r\n    None\r\n.NOTES\r\n    Minimum OS Architecture Supported: Windows 10, Server 2016\r\n    Release Notes: Renamed script and added Script Variable support\r\nBy using this script, you indicate your acceptance of the following legal terms as well as our Terms of Use at https:\/\/www.ninjaone.com\/terms-of-use.\r\n    Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms. \r\n    Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party. \r\n    Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library or website belonging to or under the control of any other software provider. \r\n    Warranty Disclaimer: The script is provided \u201cas is\u201d and \u201cas available\u201d, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations. \r\n    Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks. \r\n    Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script. \r\n    EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).\r\n#&gt;\r\n\r\n[CmdletBinding()]\r\nparam (\r\n    [Parameter()]\r\n    [int]$FailedFor = \"60\",\r\n    [Parameter()]\r\n    [String]$FromCustomField,\r\n    [Parameter()]\r\n    [Switch]$IncludePaused = [System.Convert]::ToBoolean($env:includePausedReplications)\r\n)\r\nbegin {\r\n\r\n    if ($env:allowedToFailForxMinutes -and $env:allowedToFailForxMinutes -notlike \"null\") { $FailedFor = $env:allowedToFailForxMinutes }\r\n    if ($env:retrieveAllowedFailureTimeFromCustomField -and $env:retrieveAllowedFailureTimeFromCustomField -notlike \"null\" ) { $FromCustomField = $env:retrieveAllowedFailureTimeFromCustomField }\r\n\r\n    function Test-IsElevated {\r\n        $id = [System.Security.Principal.WindowsIdentity]::GetCurrent()\r\n        $p = New-Object System.Security.Principal.WindowsPrincipal($id)\r\n        $p.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)\r\n    }\r\n\r\n    function Test-IsSystem {\r\n        $id = [System.Security.Principal.WindowsIdentity]::GetCurrent()\r\n        return $id.Name -like \"NT AUTHORITY*\" -or $id.IsSystem\r\n    }\r\n\r\n    if (!(Test-IsElevated) -and !(Test-IsSystem)) {\r\n        Write-Error -Message \"Access Denied. Please run with Administrator privileges.\"\r\n        exit 1\r\n    }\r\n\r\n    # This function is to make it easier to parse Ninja Custom Fields.\r\n    function Get-NinjaProperty {\r\n        [CmdletBinding()]\r\n        Param(\r\n            [Parameter(Mandatory = $True, ValueFromPipeline = $True)]\r\n            [String]$Name,\r\n            [Parameter()]\r\n            [String]$Type,\r\n            [Parameter()]\r\n            [String]$DocumentName\r\n        )\r\n\r\n        # If we're requested to get the field value from a Ninja document we'll specify it here.\r\n        $DocumentationParams = @{}\r\n        if ($DocumentName) { $DocumentationParams[\"DocumentName\"] = $DocumentName }\r\n\r\n        # These two types require more information to parse.\r\n        $NeedsOptions = \"DropDown\",\"MultiSelect\"\r\n\r\n        # Grabbing document values requires a slightly different command.\r\n        if ($DocumentName) {\r\n            # Secure fields are only readable when they're a device custom field\r\n            if ($Type -Like \"Secure\") { throw \"$Type is an invalid type! Please check here for valid types. https:\/\/ninjarmm.zendesk.com\/hc\/en-us\/articles\/16973443979789-Command-Line-Interface-CLI-Supported-Fields-and-Functionality\" }\r\n\r\n            # We'll redirect the error output to the success stream to make it easier to error out if nothing was found or something else went wrong.\r\n            Write-Host \"Retrieving value from Ninja Document...\"\r\n            $NinjaPropertyValue = Ninja-Property-Docs-Get -AttributeName $Name @DocumentationParams 2&gt;&amp;1\r\n\r\n            # Certain fields require more information to parse.\r\n            if ($NeedsOptions -contains $Type) {\r\n                $NinjaPropertyOptions = Ninja-Property-Docs-Options -AttributeName $Name @DocumentationParams 2&gt;&amp;1\r\n            }\r\n        }\r\n        else {\r\n            # We'll redirect error output to the success stream to make it easier to error out if nothing was found or something else went wrong.\r\n            $NinjaPropertyValue = Ninja-Property-Get -Name $Name 2&gt;&amp;1\r\n\r\n            # Certain fields require more information to parse.\r\n            if ($NeedsOptions -contains $Type) {\r\n                $NinjaPropertyOptions = Ninja-Property-Options -Name $Name 2&gt;&amp;1\r\n            }\r\n        }\r\n\r\n        # If we received some sort of error it should have an exception property and we'll exit the function with that error information.\r\n        if ($NinjaPropertyValue.Exception) { throw $NinjaPropertyValue }\r\n        if ($NinjaPropertyOptions.Exception) { throw $NinjaPropertyOptions }\r\n\r\n        # This switch will compare the type given with the quoted string. If it matches, it'll parse it further; otherwise, the default option will be selected.\r\n        switch ($Type) {\r\n            \"Attachment\" {\r\n                # Attachments come in a JSON format this will convert it into a PowerShell Object.\r\n                $NinjaPropertyValue | ConvertFrom-Json\r\n            }\r\n            \"Checkbox\" {\r\n                # Checkbox's come in as a string representing an integer. We'll need to cast that string into an integer and then convert it to a more traditional boolean.\r\n                [System.Convert]::ToBoolean([int]$NinjaPropertyValue)\r\n            }\r\n            \"Date or Date Time\" {\r\n                # In Ninja Date and Date\/Time fields are in Unix Epoch time in the UTC timezone the below should convert it into local time as a datetime object.\r\n                $UnixTimeStamp = $NinjaPropertyValue\r\n                $UTC = (Get-Date \"1970-01-01 00:00:00\").AddSeconds($UnixTimeStamp)\r\n                $TimeZone = [TimeZoneInfo]::Local\r\n                [TimeZoneInfo]::ConvertTimeFromUtc($UTC, $TimeZone)\r\n            }\r\n            \"Decimal\" {\r\n                # In ninja decimals are strings that represent a decimal this will cast it into a double data type.\r\n                [double]$NinjaPropertyValue\r\n            }\r\n            \"Device Dropdown\" {\r\n                # Device Drop-Downs Fields come in a JSON format this will convert it into a PowerShell Object.\r\n                $NinjaPropertyValue | ConvertFrom-Json\r\n            }\r\n            \"Device MultiSelect\" {\r\n                # Device Multi-Select Fields come in a JSON format this will convert it into a PowerShell Object.\r\n                $NinjaPropertyValue | ConvertFrom-Json\r\n            }\r\n            \"Dropdown\" {\r\n                # Drop-Down custom fields come in as a comma-separated list of GUIDs; we'll compare these with all the options and return just the option values selected instead of a GUID.\r\n                $Options = $NinjaPropertyOptions -replace '=', ',' | ConvertFrom-Csv -Header \"GUID\", \"Name\"\r\n                $Options | Where-Object { $_.GUID -eq $NinjaPropertyValue } | Select-Object -ExpandProperty Name\r\n            }\r\n            \"Integer\" {\r\n                # Cast's the Ninja provided string into an integer.\r\n                if($NinjaPropertyValue){\r\n                    [int]$NinjaPropertyValue\r\n                }else{\r\n                    $NinjaPropertyValue\r\n                }\r\n            }\r\n            \"MultiSelect\" {\r\n                # Multi-Select custom fields come in as a comma-separated list of GUID's we'll compare these with all the options and return just the option values selected instead of a guid.\r\n                $Options = $NinjaPropertyOptions -replace '=', ',' | ConvertFrom-Csv -Header \"GUID\", \"Name\"\r\n                $Selection = ($NinjaPropertyValue -split ',').trim()\r\n\r\n                foreach ($Item in $Selection) {\r\n                    $Options | Where-Object { $_.GUID -eq $Item } | Select-Object -ExpandProperty Name\r\n                }\r\n            }\r\n            \"Organization Dropdown\" {\r\n                # Turns the Ninja provided JSON into a PowerShell Object.\r\n                $NinjaPropertyValue | ConvertFrom-Json\r\n            }\r\n            \"Organization Location Dropdown\" {\r\n                # Turns the Ninja provided JSON into a PowerShell Object.\r\n                $NinjaPropertyValue | ConvertFrom-Json\r\n            }\r\n            \"Organization Location MultiSelect\" {\r\n                # Turns the Ninja provided JSON into a PowerShell Object.\r\n                $NinjaPropertyValue | ConvertFrom-Json\r\n            }\r\n            \"Organization MultiSelect\" {\r\n                # Turns the Ninja provided JSON into a PowerShell Object.\r\n                $NinjaPropertyValue | ConvertFrom-Json\r\n            }\r\n            \"Time\" {\r\n                # Time fields are given as a number of seconds starting from midnight. This will convert it into a datetime object.\r\n                $Seconds = $NinjaPropertyValue\r\n                $UTC = ([timespan]::fromseconds($Seconds)).ToString(\"hh\\:mm\\:ss\")\r\n                $TimeZone = [TimeZoneInfo]::Local\r\n                $ConvertedTime = [TimeZoneInfo]::ConvertTimeFromUtc($UTC, $TimeZone)\r\n\r\n                Get-Date $ConvertedTime -DisplayHint Time\r\n            }\r\n            default {\r\n                # If no type was given or not one that matches the above types just output what we retrieved.\r\n                $NinjaPropertyValue\r\n            }\r\n        }\r\n    }\r\n}\r\nprocess {\r\n    if ($FromCustomField) {\r\n        try{\r\n            $CustomFieldValue = Get-NinjaProperty -Name $FromCustomField -Type \"Integer\"\r\n        }catch{\r\n            Write-Warning \"$($_.ToString())\"\r\n        }\r\n\r\n        if($CustomFieldValue){\r\n            $FailedFor = $CustomFieldValue\r\n        }else{\r\n            Write-Warning \"Custom Field $FromCustomField was empty?\"\r\n        }\r\n    }\r\n\r\n    if($FailedFor -gt 0){\r\n        $FailedFor = $FailedFor * -1\r\n    }\r\n\r\n    $Threshold = (Get-Date).AddMinutes($FailedFor)\r\n    Write-Host \"Checking vm's that have not replicated prior to $Threshold.\"\r\n\r\n    $Failed = New-Object System.Collections.Generic.List[string]\r\n    $UnhealthyVMs = Get-VMReplication | Where-Object { $_.Health -notlike \"Normal\" -and $_.LastReplicationTime -lt $Threshold -and $_.State -notlike \"Suspended\" }\r\n    $PausedVMs = Get-VMReplication | Where-Object { $_.LastReplicationTime -lt $Threshold -and $_.State -like \"Suspended\" }\r\n\r\n    if ($UnhealthyVMs) {\r\n        $Failed.Add($UnhealthyVMs)\r\n    }\r\n    \r\n    if ($PausedVMs) {\r\n        Write-Warning \"Some of the vm's currently have replication paused!\"\r\n\r\n        if(-not $IncludePaused){\r\n            Write-Warning \"Please use 'Include Paused Replications' to include paused replications in the alert. Otherwise, they will be skipped.\"\r\n        }\r\n    }\r\n\r\n    if ($PausedVMs -and $IncludePaused) {\r\n        $Failed.Add($PausedVMs)\r\n    }\r\n\r\n    if ($Failed) {\r\n        Write-Error \"Hyper-V Replication is currently failing!\"\r\n        Get-VMReplication | Format-Table -Property VMName, PrimaryServer, State, Health, LastReplicationTime | Out-String | Write-Host\r\n        exit 1\r\n    }\r\n    else {\r\n        Write-Host \"No failing replications detected prior to $Threshold.\"\r\n\r\n        Get-VMReplication | Format-Table -Property VMName, PrimaryServer, State, Health, LastReplicationTime | Out-String | Write-Host\r\n        exit 0\r\n    }\r\n}end {\r\n    \r\n    \r\n    \r\n}<\/pre>\n<p>&nbsp;<\/p>\n\n<div class=\"in-context-cta\"><p>Accede a m\u00e1s de 300 scripts en el Dojo de NinjaOne<\/p>\n<p><a href=\"https:\/\/www.ninjaone.com\/es\/prueba-gratuita-formulario\/\">Obt\u00e9n acceso<\/a><\/p>\n<\/div>\n<h2>An\u00e1lisis detallado<\/h2>\n<p>El script es una utilidad de PowerShell dise\u00f1ada para llevar a cabo la supervisi\u00f3n de la replicaci\u00f3n de Hyper-V. Comprueba el estado de replicaci\u00f3n y el estado de cada m\u00e1quina virtual, alertando a los administradores si hay alg\u00fan problema. Los componentes clave del script incluyen:<\/p>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\"><strong>Vinculaci\u00f3n y par\u00e1metros del cmdlet<\/strong>: el script utiliza funciones avanzadas, permitiendo par\u00e1metros como <strong>-FailedFor<\/strong>, <strong>-FromCustomField<\/strong> y <strong>-IncludePaused<\/strong>.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"2\" data-aria-level=\"1\"><strong>Variables de entorno y funciones<\/strong>: utiliza funciones personalizadas y variables de entorno para determinar permisos elevados y recuperar valores de campos personalizados.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\"><strong>Proceso principal<\/strong>: el script eval\u00faa el estado y el tiempo de replicaci\u00f3n de cada m\u00e1quina virtual, compar\u00e1ndolos con los umbrales especificados. Si alguna m\u00e1quina virtual no se ha replicado en el plazo designado o se encuentra en un estado anormal, se activa una alerta.<\/li>\n<\/ul>\n<p>Este script podr\u00eda representarse visualmente en un diagrama de flujo, detallando los pasos desde la inicializaci\u00f3n, la parametrizaci\u00f3n, la comprobaci\u00f3n de permisos, hasta el an\u00e1lisis final y la alerta.<\/p>\n<h2>Posibles casos de uso<\/h2>\n<p>Imagina un administrador de TI en una empresa mediana con un entorno virtualizado robusto que utiliza Hyper-V. Desplegar\u00eda este script para supervisar regularmente el estado de replicaci\u00f3n de las m\u00e1quinas virtuales, identificando y resolviendo r\u00e1pidamente cualquier problema de replicaci\u00f3n, garantizando as\u00ed la continuidad del negocio.<\/p>\n<h2>Comparaciones<\/h2>\n<p>Tradicionalmente, la supervisi\u00f3n de la replicaci\u00f3n de Hyper-V implica comprobaciones manuales o scripts menos sofisticados. Este script, sin embargo, automatiza el proceso y proporciona una supervisi\u00f3n m\u00e1s completa y personalizable. Supera en eficacia y escalabilidad a los comandos b\u00e1sicos de PowerShell o a las comprobaciones manuales de la interfaz gr\u00e1fica de usuario.<\/p>\n<h2>FAQ<\/h2>\n<p><strong>P: \u00bfEste script se puede ejecutar en cualquier versi\u00f3n de PowerShell?<\/strong><br \/>\nR: Requiere PowerShell 5.1 o versiones posteriores.<\/p>\n<p><strong>P: \u00bfEs necesario ejecutar el script con privilegios de administrador?<\/strong><br \/>\nR: S\u00ed, el script comprueba si hay privilegios elevados, ya que necesita acceder a los detalles de replicaci\u00f3n de la m\u00e1quina virtual.<\/p>\n<p><strong>P: \u00bfC\u00f3mo puedo personalizar el umbral de alerta?<\/strong><br \/>\nR: Utiliza el par\u00e1metro <strong>-FailedFor<\/strong> para establecer un intervalo de tiempo personalizado en minutos.<\/p>\n<h2>Implicaciones<\/h2>\n<p>Aunque este script mejora la supervisi\u00f3n de la replicaci\u00f3n de Hyper-V, tambi\u00e9n subraya la necesidad de adoptar medidas proactivas de seguridad inform\u00e1tica. La detecci\u00f3n y resoluci\u00f3n r\u00e1pidas de los problemas de replicaci\u00f3n son vitales para mantener la integridad y disponibilidad de los datos.<\/p>\n<h2>Recomendaciones<\/h2>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"4\" data-aria-level=\"1\">Ejecuta regularmente el script para garantizar una supervisi\u00f3n continua.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"5\" data-aria-level=\"1\">Ajusta el par\u00e1metro <strong>-FailedFor<\/strong> en funci\u00f3n de las necesidades espec\u00edficas del entorno.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"5\" data-aria-level=\"1\">Aseg\u00farate de que PowerShell 5.1 o una versi\u00f3n posterior est\u00e1 instalado y en ejecuci\u00f3n con los permisos necesarios.<\/li>\n<\/ul>\n<h2>Reflexiones finales<\/h2>\n<p>En el contexto de la gesti\u00f3n de entornos virtualizados, herramientas como NinjaOne proporcionan una plataforma integral para <a href=\"https:\/\/www.ninjaone.com\/es\/enterprise-it-management\/infraestructura\/\">supervisar y gestionar la infraestructura de TI<\/a>. La incorporaci\u00f3n de un script como este en un conjunto m\u00e1s amplio de herramientas de NinjaOne puede mejorar la capacidad de una organizaci\u00f3n para gestionar entornos Hyper-V de manera eficiente, garantizando la fiabilidad y el rendimiento.<\/p>\n","protected":false},"author":35,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"_relevanssi_hide_post":"","_relevanssi_hide_content":"","_relevanssi_pin_for_all":"","_relevanssi_pin_keywords":"","_relevanssi_unpin_keywords":"","_relevanssi_related_keywords":"","_relevanssi_related_include_ids":"","_relevanssi_related_exclude_ids":"","_relevanssi_related_no_append":"","_relevanssi_related_not_related":"","_relevanssi_related_posts":"","_relevanssi_noindex_reason":"","_lmt_disableupdate":"no","_lmt_disable":""},"operating_system":[4212],"use_cases":[4263],"class_list":["post-509956","script_hub","type-script_hub","status-publish","hentry","script_hub_category-windows"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/script_hub\/509956","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/script_hub"}],"about":[{"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/types\/script_hub"}],"author":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/comments?post=509956"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/media?parent=509956"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/operating_system?post=509956"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/use_cases?post=509956"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}