Hi All,
Still picking up powershell so please let me know if you see any obvious
blunders: I see it say the collection is of a fixed size but how do I remove?
I have declared an array with $array="name1","name2", etc...
I can access each element with $array[0]...
I can use $array += "name5,"name6" but I can not figure out how to remove an
element
I have tried the Remove method without any luck as well as -=
PS C:\WINDOWS\system32> $array.Remove("cxsupportsystems")
Exception calling "Remove" with "1" argument(s): "Collection was of a fixed
size."
At line:1 char:1
+ $array.Remove("cxsupportsystems")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : NotSupportedException
PS C:\WINDOWS\system32> $array
kcfileserver
wnweb01
pvfile01
corpcxtsgp01
cxsupportsystems
Lastly - formatting question:
Is there any way to just crop out the rest and keep the destination /
IPv4Address info? I tried format-table / select-object but it does not do what
I want. I've tried piping after the test-connection in the scriptblock but
output is not what I want
PS C:\WINDOWS\system32> foreach ($comp in $array){Test-Connection $comp -Count
1}
Source Destination IPV4Address IPV6Address
Bytes Time(ms)
------ ----------- ----------- -----------
----- --------
L-SM-RPENG1 kcfileserver 172.29.133.130
32 62
L-SM-RPENG1 wnweb01 172.29.118.101
32 66
L-SM-RPENG1 pvfile01 172.29.171.28
32 72
L-SM-RPENG1 corpcxtsgp01 172.29.118.164
32 70
L-SM-RPENG1 cxsupportsys... 10.2.1.238
32 55
Thank you,
Ray