A new PowerShell V3 Cmdlet - Invoke-WebRequest

September 18, 2011 at 1:00 AMAndy Schneider

Playing around with PowerShell V3, I just came across an incredibly powerful new cmdlet called Invoke-WebRequest. This cmdlet will return content of a web site organized by properties. You can access the following properties from the returned Microsoft.PowerShell.Commands.HtmlWebResponseObject.

AllElements

BaseResponse

Content

Forms

Headers

Images

InputFields

Links

ParsedHTML

RawContent

RawContentLength

RawcontentStream

Scripts

StatusCode

StatusDescription

With this cmdlet,I was able to get all the links on my blog

$blog = invoke-webrequest get-powershell.com

$blog.links

This is really going to make it super easy to script against web pages and parse them when you don’t have a web service to hit. Again, PowerShell making it easy to reach into a messy world.

Posted in: PowerShell | V3 | Web

Tags:

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading