How to get website links using Invoke-WebRequest in PowerShell?

To get the links present on the website using PowerShell, we can first retrieve the data from the webpage using the Invoke-WebRequest cmdlet.

$req = Invoke-WebRequest -uri ""


To retrieve only links we can use that property and there you will also find some sub-properties like InnerHTML, Innertext, href, etc as shown in the output.

$req = Invoke-WebRequest -uri ""


innerHTML : Scripts
innerText : Scripts
outerHTML : <A href="">Scripts</A>
outerText : Scripts
tagName   : A
href      :  

We need only links so we will use the href property.

$req.Links | Select -ExpandProperty href


Updated on: 18-Jan-2021

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started