$Uris = 'www.google.com', 'www.microsoft.com', 'www.stackoverflow.com' $PathTxt = "C:\temp\Uri.txt" $PathCsv = "C:\temp\Uri.csv" $uriList = @() foreach ($uri in $Uris){ $uriObject = New-Object PSObject Try{ $Response = Invoke-WebRequest -Uri $uri -ErrorAction Stop $uriObject | Add-Member -MemberType NoteProperty -Name "URL" -Value $Response.BaseResponse.ResponseUri $uriObject | Add-Member -MemberType NoteProperty -Name "Status" -Value $Response.StatusCode $uriObject | Add-Member -MemberType NoteProperty -Name "Description" -Value $Response.StatusDescription Write-Host $Response.StatusCode $Response.StatusDescription $Response.BaseResponse.ResponseUri -ForegroundColor Green $uriList += $uriObject } Catch{ Write-Host "Unable to reach $uri" -ForegroundColor Red } } $uriList | Out-File -FilePath $PathTxt -Append $uriList | Export-Csv -Path $PathCsv -NoTypeInformation -Append ################## Send Report As Email ############################### $username = "user-email-address" $password = "password" $sstr = ConvertTo-SecureString -string $password -AsPlainText -Force $cred = New-Object System.Management.Automation.PSCredential -argumentlist $username, $sstr $smtpServer = "smtp.office365.com" #if using Exchange Online, or put down the preferred smtp server address $sendTo = "user-email-address" $sentFrom = $username $messageSubject = "Test message" $body = $uriList | ConvertTo-Html | Out-String Send-MailMessage -To $sendTo ` -From $sentFrom ` -Subject $messageSubject ` -Body $body ` -BodyAsHtml ` -smtpserver $smtpServer ` -usessl ` -Credential $cred ` -Port 587