Windows Vista Forums

Ignore dead server

  1. #1


    atorres Guest

    Ignore dead server

    I am trying to create a script that reads the registry to a list of servers
    using a text file; but some of the server on the file are dead; I would like
    to know how can I create a file that reports the dead servers, and then
    continue with the next server on the list.

    NOTE: My scripts errors out once it gets to a dead server

    Here is my sample:
    $Servers = Get-Content C:\Prod\AdminScripts\PS\Trend\Trend_list.txt
    $File = "C:\Prod\AdminScripts\PS\Trend\Trend-Server.log"
    ForEach ($Serv in $Servers) {
    $reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine',
    $Serv)
    $regKey =
    $reg.OpenSubKey("SOFTWARE\\TrendMicro\\ServerProtect\\CurrentVersion")
    $regKey.GetValueNames()
    $Path = $regKey.GetValue('HomeDirectory')
    $Output = "\\$Serv\$Path"
    $Output | Out-File $File -Append
    }

      My System SpecsSystem Spec

  2.   


  3. #2


    Niro Guest

    RE: Ignore dead server

    you could use ping...do something like:

    $servers | %{$test = ping -Quiet $_.name
    if (!$test) {$_.name >> C:\notresolved.txt}
    elseif ($test.received -eq 0) {$_.name >> c:\unpingable.txt}
    elseif ($test.received -ne 0) {$_.name >> c:\alive.txt}}

    "atorres" wrote:

    > I am trying to create a script that reads the registry to a list of servers
    > using a text file; but some of the server on the file are dead; I would like
    > to know how can I create a file that reports the dead servers, and then
    > continue with the next server on the list.
    >
    > NOTE: My scripts errors out once it gets to a dead server
    >
    > Here is my sample:
    > $Servers = Get-Content C:\Prod\AdminScripts\PS\Trend\Trend_list.txt
    > $File = "C:\Prod\AdminScripts\PS\Trend\Trend-Server.log"
    > ForEach ($Serv in $Servers) {
    > $reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine',
    > $Serv)
    > $regKey =
    > $reg.OpenSubKey("SOFTWARE\\TrendMicro\\ServerProtect\\CurrentVersion")
    > $regKey.GetValueNames()
    > $Path = $regKey.GetValue('HomeDirectory')
    > $Output = "\\$Serv\$Path"
    > $Output | Out-File $File -Append
    > }

      My System SpecsSystem Spec

  4. #3


    OldDog Guest

    Re: Ignore dead server

    On Nov 24, 12:13*pm, Niro <N...@xxxxxx> wrote:

    > you could use ping...do something like:
    >
    > $servers | %{$test = ping -Quiet $_.name
    > if (!$test) {$_.name >> C:\notresolved.txt}
    > elseif ($test.received -eq 0) {$_.name >> c:\unpingable.txt}
    > elseif ($test.received -ne 0) {$_.name >> c:\alive.txt}}
    >
    >
    >
    > "atorres" wrote:

    > > I am trying to create a script that reads the registry to a list of servers
    > > using a text file; but some of the server on the file are dead; I wouldlike
    > > to know how can I create a file that reports the dead servers, and then
    > > continue with the next server on the list.
    >

    > > NOTE: My scripts errors out once it gets to a dead server
    >

    > > Here is my sample:
    > > $Servers = Get-Content C:\Prod\AdminScripts\PS\Trend\Trend_list.txt
    > > $File = "C:\Prod\AdminScripts\PS\Trend\Trend-Server.log"
    > > ForEach ($Serv in $Servers) {
    > > * *$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine',
    > > $Serv)
    > > * *$regKey =
    > > $reg.OpenSubKey("SOFTWARE\\TrendMicro\\ServerProtect\\CurrentVersion")
    > > * *$regKey.GetValueNames()
    > > * *$Path = $regKey.GetValue('HomeDirectory')
    > > * *$Output = "\\$Serv\$Path"
    > > * *$Output | Out-File $File -Append
    > > }- Hide quoted text -
    >
    > - Show quoted text -
    What if they are not dead? What if they are Linux???

    Give this a try..
    #<---------------- Begin
    ----------------------------------------------->
    $ping = New-Object System.Net.NetworkInformation.Ping
    $computerlist = Get-Content 'c:\scripts\Servers.txt'
    foreach ($srv in $computerlist)
    {
    $reply = $ping.Send($srv)
    if ($reply.status -eq "Success")
    {
    if ($reply.Options.ttl -le 64)
    {
    Write-Host $srv " probably is a Unix host"
    }
    Else
    { if ($reply.Options.ttl -ge 65)
    {
    Write-Host $srv " probably is a Windows host"
    }
    }
    }
    Else { Write-Host $srv " Does Not Ping"
    }
    }

    #<----------------------- End Script
    -------------------------------------*----->

      My System SpecsSystem Spec


Ignore dead server
Similar Threads
Thread Forum
Still Trying to KILL wmplayer.exe DEAD, DEAD, DEAD Vista General
Code 31, I can't ignore it!! Vista General
Re: Ignore The Spammer, Just FYI. Vista General
SPAM - IGNORE Vista security
SPAM - IGNORE Vista mail