10 Nov

PowerShell url checker (Check if a list of url’s is valid)

Category:General PostTag: :

Every once in a while I run across a list of url’s that for whatever reason I want to make sure are valid. I have not yet found a good way to do this in PowerShell and finally hit the case where I decided to just write what I needed.

You can download the script here.


Below is an example of how you can use it:

C:\PS>@('http://www.google.com', 'http://www.asd----fDSAWQSDF-GZz.com') | .\Check-Url.ps1

Which generates the following output:

 IsValid Url                            HttpStatus Error
 ------- ---                            ---------- -----
    True http://www.google.com                  OK
   False http://www.asd----fDSAWQSD...             System.Net.WebException: T...

Hopefully someone else finds this useful. And if there are other/better ways of accomplishing this I’d love to hear about it.