Quick and dirty way of checking links

So ho can we run through the site and check if links are ok on it? I mean if it is possible to automate this using powershell? Another thing here is how to do this fast, better in parallel threads. The problem here is that there is no threads in Powershell unfortunately. Thre are only Powershell Jobs, but they are quite heavy. So what to do and how to achive this? I’ve taken the idea from this post. In general i run Invoke-WebRequest cmdlet as a scriptblock in separate parallel runspaces. Here you can have a look. My contribution in this is not very big. I’ve just updated the scriptblock running as part of the thread like below:

$ScriptBlock = {
Param ($lnk)

$progressOld = $ProgressPreference
$obj = new-object psobject -prop @{Name = $lnk;
Status = (Invoke-WebRequest -Uri $lnk -DisableKeep).statuscode}

$ProgressPreference = $progressOld

Also i’ve added some checks to skip repeating links and links that does not start from “http*”

Quick and dirty way of checking links