I fi I run:
$B = Get-Service -DisplayName "Opsware Agent" -ComputerName testserver
And then $B, I get this:
PS Scripts:\> $B
Status Name DisplayName
------ ---- -----------
Running OpswareAgent Opsware Agent
And if I type $B.Status
PS Scripts:\> $B.status
Running
BUT! if I put it in a script like this:
$B = Get-Service -DisplayName "Opsware Agent" -ComputerName
$strComputer
$WS.cells.item($rRow, 6) = $B.DisplayName
$WS.cells.item($rRow, 7) = $B.Status
Status comes out as the number 4.
How can I get it to say Running? or failing that what does the 4 mean
and where can I find that out?
I tried this: $WS.cells.item($rRow, 7) = $B.Status.toString() and
it worked. Go figure.
Try
$WS.cells.item($rRow, 7) = [string]($B.Status)
- Larry
If you suspect that something has a type of string but it doesn't seem
so, try executing
$B.status.Gettype()
and you'll quickly find out what type it actually is.
In this case:
PS C:> $B.status.Gettype()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True ServiceControllerStatus System.Enum
The convenience of implicit casts to [string] on output
to the console can mislead you.
- Larry
-Paul
"OldDog" wrote:
> .
>