Hello,
Hoping someone can help as i cant find an answer to this. In PowerShell i'm trying to add a new proprty to an array i have imported:
To confirm it looks like this when its imported:
PS C:\Windows\system32> $ImportedForAppend
ConnectionName : AlexanderSpirit 10.13.126.0 (vessel) (Not being upgraded)
ID : 9c503373-a37f-4f08-9cce-748721b0238e
Status : DOWN :-( 25-02:1224
IP : 10.13.126.250
PingNumber : 0
TimeStamp : 25-02-2020:1224
ConnectionName : BahrainSpirit 10.12.24.0 (vessel)
ID : 8d2ce4a0-bacc-477d-89ca-a02f8d1014fd
Status : FAST 174ms 25-02:1224
IP : 10.12.24.250
PingNumber : 174
TimeStamp : 25-02-2020:1224
ConnectionName : BarcelonaSpirit 10.12.18.0 (vessel)
ID : c7a783b5-e650-4023-a58b-2739038b1b8b
Status : FAST 737ms 25-02:1224
IP : 10.12.18.250
PingNumber : 737
TimeStamp : 25-02-2020:1224
PS C:\Windows\system32> $ImportedForAppend.GetType();
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Object[] System.Array
Now i'm trying to add a new property to the array with an updated time stamp and a new ping number, so it looks like this:
ConnectionName : AlexanderSpirit 10.13.126.0 (vessel) (Not being upgraded)
ID : 9c503373-a37f-4f08-9cce-748721b0238e
Status : DOWN :-( 25-02:1224
IP : 10.13.126.250
PingNumber : 0
TimeStamp : 25-02-2020:1224
25-02-2020:1250: 677
ConnectionName : BahrainSpirit 10.12.24.0 (vessel)
ID : 8d2ce4a0-bacc-477d-89ca-a02f8d1014fd
Status : FAST 174ms 25-02:1224
IP : 10.12.24.250
PingNumber : 174
TimeStamp : 25-02-2020:1224
25-02-2020:1250: 1344
ConnectionName : BarcelonaSpirit 10.12.18.0 (vessel)
ID : c7a783b5-e650-4023-a58b-2739038b1b8b
Status : FAST 737ms 25-02:1224
IP : 10.12.18.250
PingNumber : 737
TimeStamp : 25-02-2020:1224
25-02-2020:1250: 566
Question is how to target a specific "ConnectionName" and add a new property with the name/value so the layout stays the same?
I know i can use the below to add a new member but its adding a property to each group and i want to only target certain ones:
$ImportedForAppend | Add-Member -MemberType NoteProperty -Name $Vessel.TimeStamp -Value $CurrentStatusList.PingNumber
ConnectionName : AlexanderSpirit 10.13.126.0 (vessel) (Not being upgraded)
ID : 9c503373-a37f-4f08-9cce-748721b0238e
Status : DOWN :-( 25-02:1253
IP : 10.13.126.250
PingNumber : 0
TimeStamp : 25-02-2020:1253
Test : 455
ConnectionName : BahrainSpirit 10.12.24.0 (vessel)
ID : 8d2ce4a0-bacc-477d-89ca-a02f8d1014fd
Status : FAST 221ms 25-02:1253
IP : 10.12.24.250
PingNumber : 221
TimeStamp : 25-02-2020:1253
Test : 455
ConnectionName : BarcelonaSpirit 10.12.18.0 (vessel)
ID : c7a783b5-e650-4023-a58b-2739038b1b8b
Status : FAST 674ms 25-02:1253
IP : 10.12.18.250
PingNumber : 674
TimeStamp : 25-02-2020:1253
Test : 455
How to add only one extra property as below to say the "ConnectionName" "BarcelonaSpirit 10.12.18.0 (vessel)"
ConnectionName : AlexanderSpirit 10.13.126.0 (vessel) (Not being upgraded)
ID : 9c503373-a37f-4f08-9cce-748721b0238e
Status : DOWN :-( 25-02:1253
IP : 10.13.126.250
PingNumber : 0
TimeStamp : 25-02-2020:1253
ConnectionName : BahrainSpirit 10.12.24.0 (vessel)
ID : 8d2ce4a0-bacc-477d-89ca-a02f8d1014fd
Status : FAST 221ms 25-02:1253
IP : 10.12.24.250
PingNumber : 221
TimeStamp : 25-02-2020:1253
Test : 455
ConnectionName : BarcelonaSpirit 10.12.18.0 (vessel)
ID : c7a783b5-e650-4023-a58b-2739038b1b8b
Status : FAST 674ms 25-02:1253
IP : 10.12.18.250
PingNumber : 674
TimeStamp : 25-02-2020:1253