Home

Published

- 1 min read

Iterating through key names from a PSCustomObject Powershell

img of Iterating through key names from a PSCustomObject Powershell

The solution for this is noted below

Iterating through key names from a PSCustomObject Powershell

Solution

   $ipinfo = Invoke-WebRequest 'http://ipinfo.io/json' -UseBasicParsing | ConvertFrom-Json
foreach ($info in $ipinfo.PSObject.Properties) {
    $info.Name
    $info.Value
    '--' # <-- Seeing this double hash proves we're iterating fully.
}

Try other methods by searching on the site. That is if this doesn’t work