
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 "https://theautomationcode.com" $req
Output
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 "https://theautomationcode.com" $req.Links
Output
innerHTML : Scripts innerText : Scripts outerHTML : <A href="https://theautomationcode.com/scripts/">Scripts</A> outerText : Scripts tagName : A href : https://theautomationcode.com/scripts/
We need only links so we will use the href property.
$req.Links | Select -ExpandProperty href
Output
https://theautomationcode.com/2020/11/ https://theautomationcode.com/author/chiragce17/ https://theautomationcode.com/category/powershell/ https://theautomationcode.com/category/troubleshooting/
Advertisements