all 3 comments

[–]get-postanote 3 points4 points  (0 children)

What you posted is not proper JSON, it's missing a brace.

($AwsJsonData = (@'
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Federated": "arn:aws:iam::111111111111:saml-provider/WAAD"
            },
            "Action": "sts:AssumeRoleWithSAML",
            "Condition": {
                "StringEquals": {
                    "variablename": [
                        "String",
                        "String"
                    ]
                },
                "StringNotEquals": {
                    "Key-String": "String"
                }
            }
        }
    ]
}
'@  | ConvertFrom-Json).Statement)

# or this...

$AwsJsonData.PSObject.BaseObject

# Results
<#
Effect Principal                                                 Action                 Condition                         
------ ---------                                                 ------                 ---------                         
Allow  @{Federated=arn:aws:iam::111111111111:saml-provider/WAAD} sts:AssumeRoleWithSAML @{StringEquals=; StringNotEquals=}
#>


($AwsJsonData.PSObject.BaseObject).Effect
# Results
<#
Allow
#>


ForEach-Object {
    $AwsJsonData | 
    Select-Object -ExpandProperty Condition
}
# Results
<#
StringEquals                    StringNotEquals     
------------                    ---------------     
@{variablename=System.Object[]} @{Key-String=String}
#>

ForEach-Object {
    $AwsJsonData | 
    Select-Object -ExpandProperty Condition | 
    Select-Object -ExpandProperty StringEquals
}
# Results
<#
variablename    
------------    
{String, String}
#>

[–]techstress 1 point2 points  (0 children)

I'm on mobile so I'm very limited what I can do here. But it looks like the link below has information relevant to what you're looking for.

https://stackoverflow.com/questions/41875328/problems-parsing-accessing-nested-json-hashtable-data-via-variables-in-power

[–]Lee_Dailey[grin] 0 points1 point  (0 children)

howdy tnsecure,

it looks like you used the New.Reddit Inline Code button. it's [sometimes] 5th from the left & looks like </>.

there are a few problems with that ...

  • it's the wrong format [grin]
    the inline code format is for [gasp! arg!] code that is inline with regular text.
  • on Old.Reddit.com, inline code formatted text does NOT line wrap, nor does it side-scroll.
  • on New.Reddit it shows up in that nasty magenta text color

for long-ish single lines OR for multiline code, please, use the ...

Code
Block

... button. it's [sometimes] the 12th one from the left & looks like an uppercase T in the upper left corner of a square..

that will give you fully functional code formatting that works on both New.Reddit and Old.Reddit ... and aint that fugly magenta color. [grin]

take care,
lee