Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Setting properties of WMI objects prior to executing a method

Reply
 
Old 01-18-2007   #1 (permalink)
Andy Webster


 
 

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 SpecsSystem Spec
Old 01-18-2007   #2 (permalink)
$hay


 
 

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 SpecsSystem Spec
Old 01-18-2007   #3 (permalink)
Andy Webster


 
 

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 SpecsSystem Spec
Reply

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


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46