Automation RRS feed

  • Question

  • We want ping multiple servers and if th 80% of the servers are not able to ping it should show the result as "Initiate the failover"

    I have developed a below logic but it is not taking the server names from the txt file.

    I require guidance regarding the same

    $servers = Get-Content -Path "C:\Users\020943\Desktop\failover.txt"

    $up = $servers | Where-Object{Test-Connection -ComputerName $_.ServerName -Count 2 -Quiet}

    $percentDown = ($servers.Count - $up.Count) / $servers.Count * 100
    if($percentDown -ge 80)
        Write-Host "It is online"
        Write-Host  "Initiate a failover"

    Thursday, July 5, 2018 4:47 AM