/build/static/layout/Breadcrumb_cap_w.png

issues with mismatched NetBIOS & DNS Host names ..

Hi,

we have a couple of issues where mismatched NetBIOS & DNS Hostnames on machines are affecting a variety of things including SMS, SCCM activities + Sophos Deployments

We are seeking a script to check & confirm the names are mismatched, issue a nbtstat -RR, & export the NetBIOS & DNS Host names to a file..
We are then intending to forward this file to our "Hostmaster" who administers our DNS to alter DNS names to match the NetBIOS names.

Has anyone done this or parts of this & can share their work with me please..


_____________________________


M H Rich

0 Comments   [ + ] Show comments

Answers (5)

Posted by: admrich 14 years ago
Senior Yellow Belt
0
ORIGINAL: admrich


Hi,

we have a couple of issues where mismatched NetBIOS & DNS Hostnames on machines are affecting a variety of things including SMS, SCCM activities + Sophos Deployments

We are seeking a script to check & confirm the names are mismatched, issue a nbtstat -RR, & export the NetBIOS & DNS Host names to a file..
We are then intending to forward this file to our "Hostmaster" who administers our DNS to alter DNS names to match the NetBIOS names.

Has anyone done this or parts of this & can share their work with me please..


_____________________________


M H Rich



Ooops, & also.. need to check/confirm that the machines isn't disabled in Active Directory ?!
Posted by: anonymous_9363 14 years ago
Red Belt
0
Done properly, scripts like this are distinctly non-trivial and you are unlikely to find anything suitable off-the-shelf or for free.

Some searching will undoubtedly locate scripts which do parts of what you want: you could then stitch them together. A good start would be the Domain Inventory Reporting tool from MouseTrax (no affiliation, etc.). There are some good AD scripts on computerperformance
Posted by: admrich 14 years ago
Senior Yellow Belt
0
ORIGINAL: VBScab

Done properly, scripts like this are distinctly non-trivial and you are unlikely to find anything suitable off-the-shelf or for free.

Some searching will undoubtedly locate scripts which do parts of what you want: you could then stitch them together. A good start would be the Domain Inventory Reporting tool from MouseTrax (no affiliation, etc.). There are some good AD scripts on computerperformance



Many thx for your response. Parts is pretty much all that I'm expecting & stitching was what I was hoping to do given the parts are there to start with :)
Posted by: Byoung4now 14 years ago
Senior Yellow Belt
0
I will give this one a quick try from all the pieces of scripts I collected off the internet. :-)

first find out if Name and DNShost name are different
Option Explicit
Dim objWMIService, objItem, colItems, strComputer
Dim Name, DNSName ,strQuery

' On Error Resume Next
strComputer = "LocalHost"

Set objWMIService = GetObject("winmgmts:\\" _
& strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery(_
"Select * from Win32_ComputerSystem")
For Each objItem in colItems
Name = objItem.Name
DNSName = objItem.DNSHostName
Next



Then a function to find the computer in AD and then I made another from it to check Account disabled


Public Function SearchDistinguishedName(ByVal vSAN, byVal vType)
' Function: SearchDistinguishedName
' Description: Searches the DistinguishedName for a given SamAccountName
' Parameters: ByVal vSAN - The SamAccountName to search
' Returns: The Name
Dim oRootDSE, oConnection, oCommand, oRecordSet

Set oRootDSE = GetObject("LDAP://rootDSE")
Set oConnection = CreateObject("ADODB.Connection")
oConnection.Open "Provider=ADsDSOObject;"
Set oCommand = CreateObject("ADODB.Command")
oCommand.ActiveConnection = oConnection
oCommand.CommandText = "<LDAP://" & oRootDSE.get("defaultNamingContext") & _
">;(&(objectCategory="&vType&")(samAccountName=" & vSAN & "));Name;subtree"
Set oRecordSet = oCommand.Execute
On Error Resume Next
If Error = 0 Then
SearchDistinguishedName = oRecordSet.Fields("Name")
Else
SearchDistinguishedName = "Error"
On Error GoTo 0
End If
oConnection.Close
Set oRecordSet = Nothing
Set oCommand = Nothing
Set oConnection = Nothing
Set oRootDSE = Nothing
End Function
Public Function AccountNotLocked(ByVal vSAN, byVal vType)
' Function: SearchDistinguishedName
' Description: Searches the DistinguishedName for a given SamAccountName
' Parameters: ByVal vSAN - The SamAccountName to search
' Returns: The Name
Dim oRootDSE, oConnection, oCommand, oRecordSet

Set oRootDSE = GetObject("LDAP://rootDSE")
Set oConnection = CreateObject("ADODB.Connection")
oConnection.Open "Provider=ADsDSOObject;"
Set oCommand = CreateObject("ADODB.Command")
oCommand.ActiveConnection = oConnection
oCommand.CommandText = "<LDAP://" & oRootDSE.get("defaultNamingContext") & _
">;(&(objectCategory="&vType&")(samAccountName=" & vSAN & ")!(userAccountControl:1.2.840.113556.1.4.803:=2 ));Name;subtree"
Set oRecordSet = oCommand.Execute
On Error Resume Next
If Error = 0 Then
SearchDistinguishedName = oRecordSet.Fields("Name")
Else
SearchDistinguishedName = "Error"
On Error GoTo 0
End If
oConnection.Close
Set oRecordSet = Nothing
Set oCommand = Nothing
Set oConnection = Nothing
Set oRootDSE = Nothing
End Function

Lastly a little nested IF to compare all the results.

If UCase(Name) <> UCase(DNSName) Then
If SearchDistinguishedName (Name & "$" , "COMPUTER") <> "Error" Then
MsgBox "This PC has a name mismatch, it's currently NOT in AD."
If AccountNotLocked (Name & "$" , "COMPUTER") <> "Error" Then
MsgBox "This PC has a name mismatch, it's currently in AD and the Account Isn't Locked."
End If
End If
End If

as far as writing a log file or doing the Wshshell.run for the nbtstat. That should be easy enough to add I think.
Posted by: anonymous_9363 14 years ago
Red Belt
0
Please try and remember to use the CODE tag when posting code or any lengthy text. Use the button marked 'code' (or '<%' on older browsers/Firefox)
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ