-1

i want to parse URLs from this RSS Feed in Powershell. https://endpoints.office.com/version/worldwide?clientRequestId=b10c5ed1-bad1-445f-b386-b919946339a7&allVersions=true&format=RSS

For Example this one: https://endpoints.office.com/changes/Worldwide/2020092900?singleVersion&clientRequestId=b10c5ed1-bad1-445f-b386-b919946339a7

However, i do not get the Json-File as a result.

How can i get the JSON-File with Powershell?

Mathias R. Jessen
  • 157,619
  • 12
  • 148
  • 206
thammi
  • 1

1 Answers1

2

RSS is just XML, so we can offload fetching and parsing of the feed to the Invoke-RestMethod cmdlet:

$feedEntries = Invoke-RestMethod 'https://endpoints.office.com/version/worldwide?clientRequestId=b10c5ed1-bad1-445f-b386-b919946339a7&allVersions=true&format=RSS'

Converting the resulting objects to JSON is as easy as grabbing the desired properties with Select-Object and piping the results to ConvertTo-Json, at which point you can output to a file with Set-Content:

$feedEntries |Select-Object title,link |ConvertTo-Json |Set-Content output.json
Mathias R. Jessen
  • 157,619
  • 12
  • 148
  • 206