View Single Post
Old 01-15-2008   #9 (permalink)
Marco Shaw [MVP]
Guest


 
 

Re: powergadget : detect service is down

Quote:

> I can either:
> 1. Provide you .NET code to call from PowerShell to do the same thing.
> 2. Help you do that digital gauge that might just say "UP" or "DOWN".
#1:
PSH> ./ping|out-gauge -type digital
PSH> get-content ping.ps1
$computer="localhost"

$ping= new-object System.Net.NetworkInformation.Ping
$response=$ping.send($computer)

if ($response.Status -eq "Success")
{
$computer+" is up"
}
else
{
$computer+" is down"
}

#2:
Using .NET to get a random number:
PSH> $rand=new-object System.Random
PSH> $rand.Next(0,5) <--Gives a random number, only 0,1,2,3 or 4
3
PSH> $rand.Next(0,5)
4
PSH> $rand.Next(0,5)
1
My System SpecsSystem Spec