Home:ALL Converter>Return type PSObject not right

Return type PSObject not right

Ask Time:2022-05-06T16:17:46         Author:iAlucard

Json Formatter

I have a situation regarding PSObject. Thing is when I write only the same PSObject in different script it returns what it should.

$returnobject = New-Object -TypeName psobject
$returnobject | Add-Member -MemberType NoteProperty -Name LocalITMail -Value "what"
$returnobject | Add-Member -MemberType NoteProperty -Name LocationSufix -Value "wont you "
$returnobject | Add-Member -MemberType NoteProperty -Name Webproxy -Value "work"
return $returnobject

I get this

enter image description here

which is good.

But when I call the function from bigger script the return type is not as the form above and I cannot access its properties.

Example:
enter image description here

What am I doing wrong, is there a way on how to return the PSObject type so I don't get this @{...} output? Thanks.

Author:iAlucard,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/72138287/return-type-psobject-not-right
yy