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. #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

  3. #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
TEST -please ignore
The core i7 machines I just built for everyone else rock! The 2006 core duo ultra portable I got handed down to me does not.
SBS Server
Still Trying to KILL wmplayer.exe DEAD, DEAD, DEAD
Vista sp1 Wmplayer.exe is causing me grief. I can't burn a CD because the drive is in use by... you guessed it...wmplayer.exe. Yes, I can start...
Vista General
Watch/Ignore
When I select Watch/Ignore for certain threads the thread's text is shown in red but the newsgroup in the left pane isn't. Is this normal? In...
Vista mail
Test, please ignore
Only testing because my new posts not longer seem to show up.
Vista General
SPAM - IGNORE
-- Zack Whittaker ZackNET Enterprises: www.zacknet.co.uk MSBlog on ResDev: www.msblog.org Vista Knowledge Base: www.vistabase.co.uk This...
Vista security
SPAM - IGNORE
-- Zack Whittaker ZackNET Enterprises: www.zacknet.co.uk MSBlog on ResDev: www.msblog.org Vista Knowledge Base: www.vistabase.co.uk This...
Vista mail