From the course: Complete Guide to PowerShell 7

Unlock this course with a free trial

Join today to access over 24,400 courses taught by industry experts.

Making HTTP requests with Invoke-RestMethod

Making HTTP requests with Invoke-RestMethod - PowerShell Tutorial

From the course: Complete Guide to PowerShell 7

Making HTTP requests with Invoke-RestMethod

- [Instructor] Now one of the powerful features of working with PowerShell is the ability to connect to remote APIs and be able to retrieve information. So what I've set up here is a API that's running on local host 8080, and I have it enabled to return some information. It'll just be some basic sample data. Now, to request that information, we're going to use invoke Rest method and pass it the URI, which will be the URL that we have here. And then I'm going to specify the method. So in this instance, I want to get information. So let's execute this command and put that into the response. I'm going to say run selection. And then when I do the response object, you can see I get some basic information, and it's just a list of fictitious security events, security event 1, 2, 3, 4, 5, all the way through to 25. So that wasn't the anonymous way of doing it. And sometimes, APIs are anonymous, so we can literally just call the endpoint and it returns the values that are there. Sometimes…

Contents