I am trying to query a service to get it's state (running, stopped, etc). I am dumping it to a CSV file.
There may be an easier way to do this.
I have it working but when it dumps to the CSV file for status I see:
@{Status=Running}
I just want to see 'Running'.
I thought that I could just trim like I would any string but not the case.
I created a test program of:
When I run it I get:
Method invocation failed because
[Selected.System.ServiceProcess.ServiceController] does not contain a method
named 'TrimStart'.
At C:\scripting\trimtest.ps1:6 char:1
+ $IMAtrim = $trimtest.TrimStart("@{Status=")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (TrimStart:String) [], Runtime
Exception
+ FullyQualifiedErrorId : MethodNotFound
Any ideas anyone ?
There may be an easier way to do this.
I have it working but when it dumps to the CSV file for status I see:
@{Status=Running}
I just want to see 'Running'.
I thought that I could just trim like I would any string but not the case.
I created a test program of:
Code:
$svcIMA = Get-Service IMAService -ComputerName SERVER01 | Select-Object Status
$IMAtrim = $trimtest.TrimStart("@{Status=")
$IMAResult = $IMAtrim.TrimEnd("}")
Write-Host $imaresult
When I run it I get:
Method invocation failed because
[Selected.System.ServiceProcess.ServiceController] does not contain a method
named 'TrimStart'.
At C:\scripting\trimtest.ps1:6 char:1
+ $IMAtrim = $trimtest.TrimStart("@{Status=")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (TrimStart:String) [], Runtime
Exception
+ FullyQualifiedErrorId : MethodNotFound
Any ideas anyone ?