![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
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
Posts: n/a
| Setting properties of WMI objects prior to executing a method Hi I have a simple script that provides a very fast ping response if machines are "alive" and reports them as available using WMI. My only issue is that some hosts are sometimes reported as unavailable even though they are available. What I believe I need to do is extend the timeout of the WMI Win32_PingStatus. Here is my script (Filename : Png.ps1): >>>>>>>>>>>>>>>>>>>>>>>>> param($Hostname) Switch($Hostname) { "" {(new-object -comobject wscript.shell).popup(" `_ Syntax is : `"Png <Hostname / IP>`"`r`n E.g. `"Png PC1`" or `"Png 192.168.1.1`" `_ `r`n`r`nPress OK to exit.",0,"Error",1); Break} default { If(((gwmi Win32_PingStatus -Filter "Address='$Hostname'").StatusCode) -eq 0) { write-host -ForegroundColor GREEN $Hostname" - AVAILABLE" } Else { write-host -ForegroundColor RED $Hostname" - UNAVAILABLE" } } } <<<<<<<<<<<<<<<<<<<< Using WMI Explorer from Sapien technologies (http://www.primalscript.com/freetools/) I can see the Win32_PingStatus has a Timeout property but how do I set that prior to it running? I have had several attempts but can't figure it out. Up for the challenge? Thanks if you are ! |
| | #2 (permalink) |
| Guest
Posts: n/a
| Re: Setting properties of WMI objects prior to executing a method try $ping = Get-WmiObject -Class Win32_PingStatus -Filter "Address='127.0.0.1' and Timeout=3000" -- $hay http://scriptolog.blogspot.com "Andy Webster" <AndyWebster@discussions.microsoft.com> wrote in message news:25FC9523-04B1-4BD9-88F5-684D7914171A@microsoft.com... > Hi > > I have a simple script that provides a very fast ping response if machines > are "alive" and reports them as available using WMI. My only issue is that > some hosts are sometimes reported as unavailable even though they are > available. What I believe I need to do is extend the timeout of the WMI > Win32_PingStatus. Here is my script (Filename : Png.ps1): > >>>>>>>>>>>>>>>>>>>>>>>>>> > param($Hostname) > > Switch($Hostname) > { > "" > {(new-object -comobject wscript.shell).popup(" `_ > Syntax is : `"Png <Hostname / IP>`"`r`n E.g. `"Png PC1`" or `"Png > 192.168.1.1`" `_ > `r`n`r`nPress OK to exit.",0,"Error",1); Break} > > default > { > If(((gwmi Win32_PingStatus -Filter "Address='$Hostname'").StatusCode) -eq > 0) > { > write-host -ForegroundColor GREEN $Hostname" - AVAILABLE" > } > Else > { > write-host -ForegroundColor RED $Hostname" - UNAVAILABLE" > } > } > } > <<<<<<<<<<<<<<<<<<<< > > Using WMI Explorer from Sapien technologies > (http://www.primalscript.com/freetools/) I can see the Win32_PingStatus > has a > Timeout property but how do I set that prior to it running? I have had > several attempts but can't figure it out. > > Up for the challenge? > Thanks if you are ! |
| |
| |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Net.WebRequest.Create objects GetResponse method returns -1.. why? | buu | .NET General | 0 | 04-25-2008 04:40 PM |
| setting batchfile to runonce prior to user logon (winxp sp2) | Ben Christian | PowerShell | 7 | 04-17-2008 09:43 AM |
| select-object not returning properties that are objects | Jason | PowerShell | 5 | 02-04-2008 09:01 AM |
| Limited properties with user objects using Get-QADUser | Kari | PowerShell | 14 | 07-17-2007 04:40 AM |
| Print out arbitrary properties of objects | =?Utf-8?B?SkogU3RyZWljaGVyLUJyZW1lcg==?= | PowerShell | 5 | 08-01-2006 12:15 PM |