There are times when the name resolution of some URL does not happen. But when you check after sometime, it works perfect. So is there any way to track this intermittent name resolution issue. Yes there is!! This script helps you to monitor name resolution of a URL for the specified time. It will track the error and time in a CSV file. You can mention the duration (minutes, hours or days) for the script to monitor the name resolution.

NOTE: The powershell process running this script will hog memory over the time, hence you require to keep a track of available memory and processor periodically.


#Enter the URL to Monitor# 
$URL = "" 
#Enter the duration to monitor. Select only one" 
$Minutes = 1 
If ($Minutes -ne $null) 
elseif ($Hours -ne $null) 
elseif ($Days -ne $null) 
$results = @() 
            if (Resolve-DnsName $URL -ErrorAction Stop) {Out-Null} 
           $ErrorString = $Error[0].Exception | Out-String 
           $ErrorString = ($ErrorString).Replace("`r`n","") 
           $TimeOfError = (Get-Date).ToString() 
           $Details = @{ 
                        Error = $ErrorString 
                        Time = $TimeOfError 
            $results +New-Object PSObject -Property $details 
            $results | Export-Csv D:\Monitoring.csv -Append -NoTypeInformation 
((Get-Date).ToString("ddMMyyyhhmm"-eq $Stoptime)