Pretty simple. Collect current public IP information as Json, convert to XML and format as .csv. Works, but often gives an error. My question is that the $Output variable has a space indent on each item after the header and first item... I know there are probably good alternatives to this, but just want to understand where the extra space comes from. This is run in ISE.
$hdr = "Fld,Type,Data" $Nl = "`r`n" $cJson = Invoke-RestMethod -Uri 'https://ipinfo.io/json' $XML = ConvertTo-Xml -As String -InputObject $cJson $Output = $XML | Select-Xml -XPath "//Property" | foreach {$_.node.Name + "," + $_.node.Type+ "," + $_.node.InnerXML+ $Nl} $Output = $hdr + $Nl + $Output $Output
Figured it out.