Function Test-DownloadUri {
Tests that a url is valid
Returns a status code from an http request of a url. Used to verify that download links work.
The url that we are checking is valid
  Status code from an http response or null if link is invalid
$uri = ""
$status = Test-DownloadUri -uri $uri
 if ($status -ne 200)
 {Write-Error "oh dear"}

        [Parameter(Mandatory = $true)]
        [string] $uri
    $httpRequest = [System.Net.WebRequest]::Create($uri)
    try {
        $httpResponse = $httpRequest.GetResponse()
        $httpStatus = $httpResponse.StatusCode
        If ($httpStatus -eq 200) { 
            Write-Verbose "Download link is OK." -Verbose 
        Else {
            Write-Error "Download link no longer works."
        Return $httpStatus
    catch {
        Write-Error "Download link no longer works."
        Return $null