Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Push json string into arraylist convert json element into string instead of remain in its original type

$
0
0
$t=@()
$r= new-object -type PSObject
class
{
[string]$a
[string[]]$b

}

$c =get-adgroupmember -recrisive $team| select SamAccountName  

$c.b = $c.SamAccountName
$c.a="dummy"
$t += $c

$r | add-member -name 'c' -type noteproperty -value $t
$r| convertto-json | out-file -filepath .\xyz.json -NOClobber -force

this script give 
{
d: [
"a" : "\"sda"\", "\sdd"\"
]
}
the json is not properly printed also shall I declare $t in class, the slashes are there




Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>