![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Testing for network availability I am trying to write some scripts that return BIOS info using WMI. I would like to check for the availability of a networked PC prior to running the WMI command. Is there an easy way to do this? I started by trying to use ping and return the ping time in ms but the command is very convoluted and still needs work. Surely there must be an easier way. The basis of my current command: (((ping $ComputerIP -n 1 | where {$_.Contains("Reply")} | split-string ":" | where {$_.Contains("time")} | split-string " ")[2]) | split-string "=")[1] | split-string "ms" |
| | #2 (permalink) |
| Guest | Re: Testing for network availability try this, TTL is available only if the destination is alive ping $ComputerIP -n 1 | if ($_.Contains("TTL")) { do something} .... $hay "Andy Webster" <AndyWebster@discussions.microsoft.com> wrote in message news:BD278623-84EA-44E7-A989-B2294F4D5A44@microsoft.com... >I am trying to write some scripts that return BIOS info using WMI. > > I would like to check for the availability of a networked PC prior to > running the WMI command. Is there an easy way to do this? > > I started by trying to use ping and return the ping time in ms but the > command is very convoluted and still needs work. Surely there must be an > easier way. > > The basis of my current command: > (((ping $ComputerIP -n 1 | where {$_.Contains("Reply")} | split-string ":" > | > where {$_.Contains("time")} | split-string " ")[2]) | split-string "=")[1] > | > split-string "ms" |
| | #3 (permalink) |
| Guest | Re: Testing for network availability maybe this can help http://lantoolbox.com/network-admini...om-powershell/ $hay "Andy Webster" <AndyWebster@discussions.microsoft.com> wrote in message news:BD278623-84EA-44E7-A989-B2294F4D5A44@microsoft.com... >I am trying to write some scripts that return BIOS info using WMI. > > I would like to check for the availability of a networked PC prior to > running the WMI command. Is there an easy way to do this? > > I started by trying to use ping and return the ping time in ms but the > command is very convoluted and still needs work. Surely there must be an > easier way. > > The basis of my current command: > (((ping $ComputerIP -n 1 | where {$_.Contains("Reply")} | split-string ":" > | > where {$_.Contains("time")} | split-string " ")[2]) | split-string "=")[1] > | > split-string "ms" |
| | #4 (permalink) |
| Guest | Re: Testing for network availability Thanks for the help $hay Could not seem to pipe into an If statement so ended up with this to develope on: ForEach ( $i in 221..225 ) { $ComputerIP = "192.168.1." + $i $PingResponse = ping $ComputerIP -n 1 #--Set $Available to false $Available = (1 -eq 2) ForEach ($line in $PingResponse) { #--If reply contains TTL set $Available to True If ($line.Contains("TTL")){$Available = (1 -eq 1)} } If($Available) { write-host -ForegroundColor GREEN $ComputerIP" - AVAILABLE" } Else { write-host -ForegroundColor RED $ComputerIP" - UNAVAILABLE" } } "$hay" wrote: > maybe this can help > > http://lantoolbox.com/network-admini...om-powershell/ > > $hay > > "Andy Webster" <AndyWebster@discussions.microsoft.com> wrote in message > news:BD278623-84EA-44E7-A989-B2294F4D5A44@microsoft.com... > >I am trying to write some scripts that return BIOS info using WMI. > > > > I would like to check for the availability of a networked PC prior to > > running the WMI command. Is there an easy way to do this? > > > > I started by trying to use ping and return the ping time in ms but the > > command is very convoluted and still needs work. Surely there must be an > > easier way. > > > > The basis of my current command: > > (((ping $ComputerIP -n 1 | where {$_.Contains("Reply")} | split-string ":" > > | > > where {$_.Contains("time")} | split-string " ")[2]) | split-string "=")[1] > > | > > split-string "ms" > > > |
| | #5 (permalink) |
| Guest | Re: Testing for network availability Check out http://sapien.eponym.com/blog/_archi...8/2549814.html which has the following example function: Function Ping-Name { PROCESS { $wmi = get-wmiobject -query "SELECT * FROM Win32_PingStatus WHERE Address = '$_'" if ($wmi.StatusCode -eq 0) { $_ } } } The wmi call basically tells the local PC to ping the remote address and returns statuscode of 0 if successful. The way this function is setup, you can use it like a cmd-let and PIPE a list of machines to ping and returns ONLY live machines. You can use IP addresses or hostnames. As an alternate to your foreach method, you can create a list of computers using: PS ps:\> $computerips = @() PS ps:\> 221..225 | % { $computerip += "192.168.1.$_" } Then pipe this to Ping-Name like so: PS ps:\> $computerips | Ping-Name -- gaurhoth http://gaurhothw.spaces.live.com/ "Andy Webster" <AndyWebster@discussions.microsoft.com> wrote in message news:B6EDED6D-8F0B-4A51-9FC4-8B4E7AB15EB4@microsoft.com... > Thanks for the help $hay > > Could not seem to pipe into an If statement so ended up with this to > develope on: > > ForEach ( $i in 221..225 ) > { > $ComputerIP = "192.168.1." + $i > > $PingResponse = ping $ComputerIP -n 1 > > #--Set $Available to false > $Available = (1 -eq 2) > > ForEach ($line in $PingResponse) > { > #--If reply contains TTL set $Available to True > If ($line.Contains("TTL")){$Available = (1 -eq 1)} > } > > If($Available) > { > write-host -ForegroundColor GREEN $ComputerIP" - AVAILABLE" > } > Else > { > write-host -ForegroundColor RED $ComputerIP" - UNAVAILABLE" > } > } > > > "$hay" wrote: > >> maybe this can help >> >> http://lantoolbox.com/network-admini...om-powershell/ >> >> $hay >> >> "Andy Webster" <AndyWebster@discussions.microsoft.com> wrote in message >> news:BD278623-84EA-44E7-A989-B2294F4D5A44@microsoft.com... >> >I am trying to write some scripts that return BIOS info using WMI. >> > >> > I would like to check for the availability of a networked PC prior to >> > running the WMI command. Is there an easy way to do this? >> > >> > I started by trying to use ping and return the ping time in ms but the >> > command is very convoluted and still needs work. Surely there must be an >> > easier way. >> > >> > The basis of my current command: >> > (((ping $ComputerIP -n 1 | where {$_.Contains("Reply")} | split-string ":" >> > | >> > where {$_.Contains("time")} | split-string " ")[2]) | split-string "=")[1] >> > | >> > split-string "ms" >> >> >> |
| | #6 (permalink) |
| Guest | Re: Testing for network availability Thanks again, now got: ForEach ( $i in 221..225 ) { $ComputerIP = "192.168.1." + $i If(((gwmi Win32_PingStatus -Filter "Address='$ComputerIP'").StatusCode) -eq 0) { write-host -ForegroundColor GREEN $ComputerIP" - AVAILABLE" } Else { write-host -ForegroundColor RED $ComputerIP" - UNAVAILABLE" } } "Gaurhoth" wrote: > Check out http://sapien.eponym.com/blog/_archi...8/2549814.html which has the following example function: > > Function Ping-Name { > PROCESS { > $wmi = get-wmiobject -query "SELECT * FROM Win32_PingStatus WHERE Address = '$_'" > if ($wmi.StatusCode -eq 0) { $_ } > } > } > > The wmi call basically tells the local PC to ping the remote address and returns statuscode of 0 if successful. The way this function is setup, you can use it like a cmd-let and PIPE a list of machines to ping and returns ONLY live machines. You can use IP addresses or hostnames. > > As an alternate to your foreach method, you can create a list of computers using: > > PS ps:\> $computerips = @() > PS ps:\> 221..225 | % { $computerip += "192.168.1.$_" } > > Then pipe this to Ping-Name like so: > > PS ps:\> $computerips | Ping-Name > > -- > > gaurhoth > http://gaurhothw.spaces.live.com/ > > > "Andy Webster" <AndyWebster@discussions.microsoft.com> wrote in message news:B6EDED6D-8F0B-4A51-9FC4-8B4E7AB15EB4@microsoft.com... > > Thanks for the help $hay > > > > Could not seem to pipe into an If statement so ended up with this to > > develope on: > > > > ForEach ( $i in 221..225 ) > > { > > $ComputerIP = "192.168.1." + $i > > > > $PingResponse = ping $ComputerIP -n 1 > > > > #--Set $Available to false > > $Available = (1 -eq 2) > > > > ForEach ($line in $PingResponse) > > { > > #--If reply contains TTL set $Available to True > > If ($line.Contains("TTL")){$Available = (1 -eq 1)} > > } > > > > If($Available) > > { > > write-host -ForegroundColor GREEN $ComputerIP" - AVAILABLE" > > } > > Else > > { > > write-host -ForegroundColor RED $ComputerIP" - UNAVAILABLE" > > } > > } > > > > > > "$hay" wrote: > > > >> maybe this can help > >> > >> http://lantoolbox.com/network-admini...om-powershell/ > >> > >> $hay > >> > >> "Andy Webster" <AndyWebster@discussions.microsoft.com> wrote in message > >> news:BD278623-84EA-44E7-A989-B2294F4D5A44@microsoft.com... > >> >I am trying to write some scripts that return BIOS info using WMI. > >> > > >> > I would like to check for the availability of a networked PC prior to > >> > running the WMI command. Is there an easy way to do this? > >> > > >> > I started by trying to use ping and return the ping time in ms but the > >> > command is very convoluted and still needs work. Surely there must be an > >> > easier way. > >> > > >> > The basis of my current command: > >> > (((ping $ComputerIP -n 1 | where {$_.Contains("Reply")} | split-string ":" > >> > | > >> > where {$_.Contains("time")} | split-string " ")[2]) | split-string "=")[1] > >> > | > >> > split-string "ms" > >> > >> > >> |
| | #7 (permalink) |
| Guest | RE: Testing for network availability Something that might be easier to work with ping $i if ($(arp -a $i) -ne "No ARP Entries Found"){ "Andy Webster" wrote: > I am trying to write some scripts that return BIOS info using WMI. > > I would like to check for the availability of a networked PC prior to > running the WMI command. Is there an easy way to do this? > > I started by trying to use ping and return the ping time in ms but the > command is very convoluted and still needs work. Surely there must be an > easier way. > > The basis of my current command: > (((ping $ComputerIP -n 1 | where {$_.Contains("Reply")} | split-string ":" | > where {$_.Contains("time")} | split-string " ")[2]) | split-string "=")[1] | > split-string "ms" |
| | #8 (permalink) |
| Guest | Re: Testing for network availability Finally, a list of available IPs and their BIOS versions, thanks for all the help: ForEach ( $i in 221..225 ) { $ComputerIP = "10.178.225." + $i If(((gwmi Win32_PingStatus -Filter "Address='$ComputerIP'").StatusCode) -eq 0) { write-host -ForegroundColor GREEN $ComputerIP - (Get-WmiObject WIN32_BIOS -ComputerName $ComputerIP).SMBIOSBIOSVersion } Else { write-host -ForegroundColor RED $ComputerIP" - UNAVAILABLE" } } "Gaurhoth" wrote: > Check out http://sapien.eponym.com/blog/_archi...8/2549814.html which has the following example function: > > Function Ping-Name { > PROCESS { > $wmi = get-wmiobject -query "SELECT * FROM Win32_PingStatus WHERE Address = '$_'" > if ($wmi.StatusCode -eq 0) { $_ } > } > } > > The wmi call basically tells the local PC to ping the remote address and returns statuscode of 0 if successful. The way this function is setup, you can use it like a cmd-let and PIPE a list of machines to ping and returns ONLY live machines. You can use IP addresses or hostnames. > > As an alternate to your foreach method, you can create a list of computers using: > > PS ps:\> $computerips = @() > PS ps:\> 221..225 | % { $computerip += "192.168.1.$_" } > > Then pipe this to Ping-Name like so: > > PS ps:\> $computerips | Ping-Name > > -- > > gaurhoth > http://gaurhothw.spaces.live.com/ > > > "Andy Webster" <AndyWebster@discussions.microsoft.com> wrote in message news:B6EDED6D-8F0B-4A51-9FC4-8B4E7AB15EB4@microsoft.com... > > Thanks for the help $hay > > > > Could not seem to pipe into an If statement so ended up with this to > > develope on: > > > > ForEach ( $i in 221..225 ) > > { > > $ComputerIP = "192.168.1." + $i > > > > $PingResponse = ping $ComputerIP -n 1 > > > > #--Set $Available to false > > $Available = (1 -eq 2) > > > > ForEach ($line in $PingResponse) > > { > > #--If reply contains TTL set $Available to True > > If ($line.Contains("TTL")){$Available = (1 -eq 1)} > > } > > > > If($Available) > > { > > write-host -ForegroundColor GREEN $ComputerIP" - AVAILABLE" > > } > > Else > > { > > write-host -ForegroundColor RED $ComputerIP" - UNAVAILABLE" > > } > > } > > > > > > "$hay" wrote: > > > >> maybe this can help > >> > >> http://lantoolbox.com/network-admini...om-powershell/ > >> > >> $hay > >> > >> "Andy Webster" <AndyWebster@discussions.microsoft.com> wrote in message > >> news:BD278623-84EA-44E7-A989-B2294F4D5A44@microsoft.com... > >> >I am trying to write some scripts that return BIOS info using WMI. > >> > > >> > I would like to check for the availability of a networked PC prior to > >> > running the WMI command. Is there an easy way to do this? > >> > > >> > I started by trying to use ping and return the ping time in ms but the > >> > command is very convoluted and still needs work. Surely there must be an > >> > easier way. > >> > > >> > The basis of my current command: > >> > (((ping $ComputerIP -n 1 | where {$_.Contains("Reply")} | split-string ":" > >> > | > >> > where {$_.Contains("time")} | split-string " ")[2]) | split-string "=")[1] > >> > | > >> > split-string "ms" > >> > >> > >> |
| | #9 (permalink) |
| Guest | RE: Testing for network availability Nevermind. I just realized the problem with that approach. Works good on the local network, but falls down once you cross a router. "Rob Campbell" wrote: > Something that might be easier to work with > > ping $i > if ($(arp -a $i) -ne "No ARP Entries Found"){ > > "Andy Webster" wrote: > > > I am trying to write some scripts that return BIOS info using WMI. > > > > I would like to check for the availability of a networked PC prior to > > running the WMI command. Is there an easy way to do this? > > > > I started by trying to use ping and return the ping time in ms but the > > command is very convoluted and still needs work. Surely there must be an > > easier way. > > > > The basis of my current command: > > (((ping $ComputerIP -n 1 | where {$_.Contains("Reply")} | split-string ":" | > > where {$_.Contains("time")} | split-string " ")[2]) | split-string "=")[1] | > > split-string "ms" |
| | #10 (permalink) |
| Guest | Re: Testing for network availability FWIW - if ([bool]$Pingresponse -like "*TTL*") "Andy Webster" wrote: > Thanks for the help $hay > > Could not seem to pipe into an If statement so ended up with this to > develope on: > > ForEach ( $i in 221..225 ) > { > $ComputerIP = "192.168.1." + $i > > $PingResponse = ping $ComputerIP -n 1 > > #--Set $Available to false > $Available = (1 -eq 2) > > ForEach ($line in $PingResponse) > { > #--If reply contains TTL set $Available to True > If ($line.Contains("TTL")){$Available = (1 -eq 1)} > } > > If($Available) > { > write-host -ForegroundColor GREEN $ComputerIP" - AVAILABLE" > } > Else > { > write-host -ForegroundColor RED $ComputerIP" - UNAVAILABLE" > } > } > > > "$hay" wrote: > > > maybe this can help > > > > http://lantoolbox.com/network-admini...om-powershell/ > > > > $hay > > > > "Andy Webster" <AndyWebster@discussions.microsoft.com> wrote in message > > news:BD278623-84EA-44E7-A989-B2294F4D5A44@microsoft.com... > > >I am trying to write some scripts that return BIOS info using WMI. > > > > > > I would like to check for the availability of a networked PC prior to > > > running the WMI command. Is there an easy way to do this? > > > > > > I started by trying to use ping and return the ping time in ms but the > > > command is very convoluted and still needs work. Surely there must be an > > > easier way. > > > > > > The basis of my current command: > > > (((ping $ComputerIP -n 1 | where {$_.Contains("Reply")} | split-string ":" > > > | > > > where {$_.Contains("time")} | split-string " ")[2]) | split-string "=")[1] > > > | > > > split-string "ms" > > > > > > |
| |
| |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Vista SP1 availability | Nick Le Lievre | Vista General | 7 | 05-02-2008 12:09 PM |
| Vista sp1 availability | Matthew | Vista General | 8 | 05-02-2008 08:59 AM |
| Re: Vista sp1 availability | housetrained | Vista General | 1 | 03-23-2008 07:05 AM |
| RC2 Availability | David Sanders | Vista General | 3 | 10-06-2006 03:38 PM |
| Clarification on RC1 Availability | Andre Da Costa [ActiveWin] | Vista General | 2 | 09-06-2006 11:29 PM |