Struggling to get output from Invoke-Restmethod into PSCustomObject in the format I want.


I am getting data from my storage cluster via its API using an Invoke-Restmethod and I am placing the result into a variable $RESTApiClusterTime

I then want to manipulate the property names to something meaningful, so have been using a PSCustomObject.

However, the resulting table is not what I am wanting and I don't know why.

My PSCustomObject looks like this:

$ClusterTime = [PSCustomObject]@{ 
 'Node' = "Node $($RESTApiClusterTime.nodes.lnn)" 
 'POSIX Time' = $($RESTApiClusterTime.nodes.time) 

and the output looks like this:

Node POSIX Time  
---- ----------  
Node 1 2 3 {1551258049, 1551258059, 1551258059}

However, I want it to look like this:

Node POSIX Time
Node 1 1551258049
Node 2 1551258059
Node 3 1551258059

I have exported the variable $RESTApiClusterTime as an .xml and attached it. It can be recreated with the command Import-Clixml RESTApiClusterTimeVariable.xml | %{ Set-Variable $_.Name $_.Value }


If anyone can help me understand what I am doing wrong and how I fix it, I would be very appreciative.



Parents Reply Children