Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

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.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

Setting properties of WMI objects prior to executing a method

Closed Thread
 
Thread Tools Display Modes
Old 01-18-2007   #1 (permalink)
Andy Webster
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 !
 
Old 01-18-2007   #2 (permalink)
$hay
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 !



 
Old 01-18-2007   #3 (permalink)
Andy Webster
Guest
 
Posts: n/a

Re: Setting properties of WMI objects prior to executing a method

Thanks once again for a quick response, so simple when you know how

 
 
Closed Thread

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








Vistax64.com 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 2005-2008

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 47 48 49