I am writing a script for my site that utilizes a JSON configuration file. The JSON is similar to the following:
"Groups": {
"GroupOne": {
"NamingFilter": {
"Not":"<SITE>-MJ*",
"Has":"*WM,*WT"
}
},
"GroupTwo": {
"NamingFilter": {
"Has":"<SITE>-MJ*, *WC,*WL"
}
},
"GroupThree": {
"NamingFilter": {
"Not":"<SITE>-MJ*",
"Has":"*WI"
}
}
}
To convert the object to something PowerShell can read, I use ConvertFrom-Json
which converts it to type PSCustomObject
.
I am at a point where I have to iterate over the Groups
and get each group name to output them and their corresponding index within the configuration's Groups
object. That is,
1. GroupOne
2. GroupTwo
3. GroupThree
The furthest I have gotten is:
foreach ($group in $configObject.Groups) {
$group
}
And all this does is output something that looks like PowerShell array notation:
@{GroupOne=; GroupTwo=; GroupThree=;}
Is this even possible with a PSCustomObject
type? I primarily code in JavaScript so perhaps I am oversimplifying (or overcomplicating it) the issue since this would be relatively easy.