I am using an object to get value of RestAPI url details which contains the assets. The location is the region where the assets are present.
I am reading the location values using import-csv menthod and using a for loop
$inventory = Import-Csv "File.csv"
$output = foreach($i in $inventory){
$RestAPIobject = Invoke-RestMethod -Method Get -uri "XXXXXXXXXXXXXXXXXXX"
$CBObject = New-Object -TypeName psobject
$CBObject | Add-Member -MemberType NoteProperty -Name Region-Value $i.region
$CBObject | Add-Member -MemberType NoteProperty -Name Assets -Value $RestAPIobject.name
$CBObject
}
I am getting the output as :-
Location Assets
Region1 {H1, H2, H3}
Region2 {A1, A2}
whereas I want the output as
Location Assets
Region1 H1
Region1 H2
Region1 H3
Region2 A1
Region2 A2
CBmember, but the output lists aAssetscolumn instead. Is this the real code you are running?