![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 ! |
My System Specs![]() |
| | #2 (permalink) |
| | 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 ! |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Setting properties of WMI objects prior to executing a method Thanks once again for a quick response, so simple when you know how |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Comparing objects with arbritrary properties. | .NET General | |||
| Net.WebRequest.Create objects GetResponse method returns -1.. why? | .NET General | |||
| setting batchfile to runonce prior to user logon (winxp sp2) | PowerShell | |||
| Limited properties with user objects using Get-QADUser | PowerShell | |||
| Print out arbitrary properties of objects | PowerShell | |||