A new PowerShell V3 Cmdlet - Invoke-WebRequest
September 18, 2011 at 1:00 AM
—
Andy 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.
ed4595ab-6e4c-4e2e-8b5c-a47f2cd9c88b|2|4.5
Posted in: PowerShell | V3 | Web
Tags: