Check if hostname exists in DNS

Site Admin
Posts: 80
Joined: Tue Jan 09, 2007 10:03 pm

Check if hostname exists in DNS

Postby Darco » Wed Jun 08, 2011 6:21 am


Hereby a small script which check if a hostname exists in DNS.

Code: Select all

function verify_host
$erroractionpreference = "SilentlyContine"
try {
catch {
   $exist = [System.Uri]::CheckHostName($_)
   if ($exist -ne 'IPv4'){
      Write-Host "Sorry, but this host doesn't exists in DNS" -foregroundcolor red -backgroundcolor yellow

$strTargetComputerAccount =$Args[0].ToUpper()


Always usefull to check when running scripts :lol:

Return to “PowerShell”

Who is online

Users browsing this forum: No registered users and 1 guest