Hi Forum,
when I write:
$a = gwmi -class win32_service -filter "Caption like '%sql%'" | ft Name, Caption, Status, StartMode, Started, StartName, State -a foreach($b in $a) { $b.Caption } $a.gettype()
..then foreach gives nothing ($b.caption) back.
$a.gettype() gives back:
IsPublic IsSerial Name BaseType -------- -------- ----
--------
True True Object[]
System.Array
when I change the code to:
$a = gwmi -class win32_service -filter "Caption like '%sql%'" foreach($b in $a) { $b.Caption } $a.gettype()all works fine and I get the captions.
In both cases $a.gettype() shows the same.
Why is Format-Table messing up the value of the variable $a? Where can I find (get-help?) the reason for that behavior?
Thanks for your help Purclot
- Edited by Purclot Thursday, January 29, 2015 1:43 PM