Who's Hungry for a REST API?
One of my favorite uses of PowerShell is how it can consume data from a REST API. You don’t have to be a web developer, although there are a few concepts you might have to pick up. Why does this matter to you? Maybe you have a third-party management solution in your organization. But it lacks PowerShell cmdlets. However, maybe it has a REST API you can access. If so, you can use the REST APIs to write your own management tools.
I thought I would share some tips and techniques for getting the most from this process.
Invoke-RestMethod
The primary command you will work with is Invoke-RestMethod
. For now, I will only focus on getting data from a web service. In most cases, the data returned by a REST API is formatted as JSON or XML data. Invoke-RestMethod
will automatically convert that output into PowerShell custom objects. Let’s look at a simple example.