title: Script to find dead website/domain
body: <p>I am working on a powershell script to find websites which are either not running on our server or pointing to another server. I am fetching all website names from a file and using it to find only those websites which are not running on our server. I'm trying to use below script but getting an error.</p>
  
  <p>As always, and help or advice would be much appreciated.</p>
  
  <pre><code>$servers = get-content "path_to_the_file"
  foreach ($server in $servers) {
  $addresses = [System.Net.Dns]::GetHostAddresses($server)
  foreach($a in $addresses) {
  "{0},{1}" -f $server, $a.IPAddressToString
   }
  }     
  </code></pre>
  
  <p>Below is the error I am getting:   </p>
  
  <pre><code>Exception calling "GetHostAddresses" with "1" argument(s): "No such host is known" At      
  C:\test1.ps1:3 char:50 + $addresses = [System.Net.Dns]::GetHostAddresses &lt;&lt;&lt;&lt; ($server) + 
  CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : 
  DotNetMethodException
  </code></pre>