Hi there!I created the following pscustomobject with a nested pscustomobject. Interestingly after Select-Object -Expandproperty the source object is changed. Do you have an answer on that?# Create array for subobject object$subobject = @()$subobject += [pscustomobject]@{'FieldName'='Value1';'FieldNameX'='Value2'}$subobject += [pscustomobject]@{'FieldName'='Value3';'FieldNameX'='Value4'}# Create hashtable$arr = @{}$arr.Object1 = $subobject$arr.NameX = 'ValueX'Write-Host 'source array:'$arr# create pscustomobject$myobject = [pscustomobject]$arrWrite-Host 'myobject before output with select-object -expandproperty:'$myobjectWrite-Host 'myobject output with select-object -expandproperty:'$myobject | Select-Object * -ExpandProperty Object1Write-Host 'myobject after output with select-object -expandproperty:'$myobject--- After running the script $myobject is changed:NameX : ValueXObject1 : {@{FieldName=Value1; FieldNameX=Value2; NameX=ValueX; Object1=System.Object[]}, @{FieldName=Value3; FieldNameX=Value4; NameX=ValueX; Object1=System.Object[]}}--- Expected content of myobject:NameX : ValueXObject1 : {@{FieldName=Value1; FieldNameX=Value2}, @{FieldName=Value3; FieldNameX=Value4}}Thank you!Have a great day!-Bruno.
Have you seen this problem before in this product?
Please wait...