Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to verify DNS to DHCP

Status
Not open for further replies.

cojast08

Technical User
Apr 4, 2008
25
0
0
US
Not for sure if I am over looking something but I have not been able to find a good way to verify that DNS entries are correct for my computers.
If anyone has an idea or has already done this and would like to share that would be awesome.

I have all my computers in a text file from AD that I would like to verify that the DNS forward and reverse Lookup zones are correct based off of the DHCP lease.
We constant are unable to communicate with computers because DNS is pointing to the wrong address and was hoping for an easier and more proactive way to catch these before they are a problem.
 
Can you give an example, just for clarification?

I believe you can query DNS with
[System.Net.Dns]::GetHostAddresses("<Hostname@Domain>")
[System.Net.Dns]::GetHostEntry("<IPAdress>")


Light travels faster than sound. That's why some people appear bright until you hear them speak.
 
This is what I got but it is not working so not for sure. Still learning this stuff.


$leases = Get-DhcpServerv4Lease -ScopeId 192.168.0.0 -ComputerName "myServer" foreach ($lease in $leases) {
$hostname = $lease.HostName
$ipAddress = $lease.IPAddress
$dnsHostNameEntry = [System.Net.Dns]::Resolve($ipaddress)
$dnsHostAddressEntry = [System.Net.Dns]::Resolve($ipaddress)

}
 
Maybe I am missing something that I don't realize. I am running powershell from a windows 7 machine using powershell v5.
I am getting this error code below. Do I need to install something else?

The term 'Get-DhcpServerv4Lease' is not recognized as the name of a cmdlet
 
What does your input file look like and does it have headers on the columns or not?


Light travels faster than sound. That's why some people appear bright until you hear them speak.
 
Well I don't have a input file as I was assuming this script was creating the file once I put in the export to csv command.
I thought that by coding the servername and scope that I would not need an input file. Again still learning all this powershell language just by reading on google so if I am doing something wrong let me know.
 
(With regards to your error) My guess is that you don't have the DhcpServer module loaded.

Run: Get-Module

If, under the name column, you don't see an entry for DhcpServer, then that's your problem.

If you have the tools installed on the server/workstation you're running the commands on, you should be able to load it by running:
Import-Module DhcpServer




Light travels faster than sound. That's why some people appear bright until you hear them speak.
 
Ok looks like the only ones I have are as followed
ISE
Microsoft.Powershell.Managment
Microsoft.Powershell.Utility

 
cojast08 said:
I have all my computers in a text file from AD that I would like to verify that the DNS forward and reverse Lookup zones are correct based off of the DHCP lease.

I may not understand exactly what you're doing, but I think you need something as the master list to check if it's even in DNS. That list can be from a text file or possibly pulled from AD.


Light travels faster than sound. That's why some people appear bright until you hear them speak.
 
OK where do I get the tools to run the DHCPServer modules... right now that is the first error that I am getting that the module or cmdlet is not valid.
Once I can get that fixed I can move on to the next issue. I might not need the computer txt answer file if I can get the DHCP to check the scopes.
 
They are the Microsoft tools: RSAT
You'll have to find the ones for the OS of the system from which you are running PowerShell.


Light travels faster than sound. That's why some people appear bright until you hear them speak.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top