?
Solved

Old Computer Names & IPs

Posted on 2011-04-19
5
Medium Priority
?
367 Views
Last Modified: 2012-05-11
I have inherited a rather large domain & the past network admin did not keep DNS or Active Directory clean by leaving the domain properly. In other words, when a new computer came in to be installed, he just unplugged it & put the new on in place with a different IP & NetBIOS name.

Now, that I've came along, I have noticed this. I have 6 domain controllers all are global catalog servers. I need to go through & manually delete numerous records.....instead of me manually pinging each IP or NetBIOS name to make sure it is alive or dead, is there any tool I can run that will check the domain for any computers that have not logged into the domain, lets say in a few weeks, so I can compare my list to that report & just delete the computers?
0
Comment
Question by:wantabe2
5 Comments
 
LVL 11

Expert Comment

by:TheGorby
ID: 35427562
I believe SpiceWorks does that, its main function is for inventory purposes but it should give you the reports you need.

http://www.spiceworks.com/
0
 
LVL 20

Expert Comment

by:thehagman
ID: 35427582
Maybe check the event log.
In the security log you should see "users" with names of the form COMPUTERNAME$
0
 
LVL 7

Accepted Solution

by:
ashutoshsapre earned 2000 total points
ID: 35427666
Use the dsquery command:

dsquery computer domainroot -inactive n

where n is number of weeks.
You can also redirect the output to a file:

dsquery computer domainroot -inactive n > C:\Inactive_Computers.txt

You can also use the following vbscript (I don't remember the source) to find out the online and offline machines, you just need to run the script:
Option Explicit
Dim Row, XL, WshShell, FileSystem, RegularExpression, Dummy, TheNVFile, TheLine
Dim Whacks, WhacksFound, WhacksPattern,  Flag, HostName, NBTable, PingReport, PingPattern
Dim IPAddress, MACPattern, MACAddress, Matches, TheMatch, Match, NBCommand, TheNBTFile
Dim IPCommand, TheIPFile, FileName, TheDate, Suggestion, Book

Const ForReading = 1
Row = 2

Set XL = WScript.CreateObject("Excel.Application")
Set WshShell = WScript.CreateObject("WScript.Shell")
Set FileSystem = CreateObject("Scripting.FileSystemObject")
Set RegularExpression = New RegExp

Dummy = WshShell.Popup ("Compiling Network Address Inventory.  Please Wait...",1,"Network Address Inventory Utility",64)

Call BuildSpreadSheet()

WshShell.Run "Cmd.exe /c Net View > C:\Windows\Temp\NetViewList.txt", 2,True
Set TheNVFile = FileSystem.OpenTextFile("C:\Windows\Temp\NetViewList.txt", ForReading, True)

Do While TheNVFile.AtEndOfStream <> True
	TheLine = TheNVFile.ReadLine
	Whacks = "\\"
	WhacksFound = FindPattern(TheLine, Whacks)
	If WhacksFound Then
		WhacksPattern = "\\\\\S*"
		Flag = "1"
		HostName = GetPattern(TheLine, WhacksPattern, Flag )
		NBTable = GetNBTable(HostName)
		MACPattern = "MAC Address = \S*"
		Flag = "2"
		MACAddress = GetPattern(NBTable, MACPattern, Flag )
		PingReport = GetIPAddress(HostName)
		PingPattern = "Reply from \S*"
		Flag = "3"
		IPAddress = GetPattern(PingReport, PingPattern, Flag )
		IPAddress = Replace(IPAddress, ":", "") 
		Call AddToSpreadSheet(HostName, IPAddress, MACAddress)
	End If
Loop    

TheNVFile.Close
FileSystem.DeleteFile("C:\Windows\Temp\NetViewList.txt")
Dummy = WshShell.Popup ("Network Address Inventory Operation Complete",5,"Network Address Inventory Utility",64 )
Call SaveSpreadSheet()
WScript.Quit

Sub BuildSpreadSheet()
	XL.Visible = True
	Set Book = XL.WorkBooks.Add
	XL.Columns(1).ColumnWidth = 20
	XL.Columns(2).ColumnWidth = 20
	XL.Columns(3).ColumnWidth = 20
	XL.Cells(1, 1).Value = "Host Name"
	XL.Cells(1, 2).Value = "IP Address"
	XL.Cells(1, 3).Value = "MAC Address"
	XL.Range("A1:C1").Select
	XL.Selection.Font.Bold = True
	XL.Selection.Font.Size = 12
End Sub

Sub AddToSpreadSheet(HostName, IPAddress, MACAddress)
	XL.Cells(Row, 1).Value = HostName
	XL.Cells(Row, 2).Value = IPAddress
	XL.Cells(Row, 3).Value = MACAddress
	Row = Row + 1
	XL.Cells(Row, 1).Select
End Sub

Sub SaveSpreadSheet()
	TheDate = Date
	TheDate = Replace(TheDate, "/", "-")
	Suggestion = "NetAI " & TheDate & ".xls"
	FileName = XL.GetSaveAsFilename(Suggestion)
	If FileName <> False Then
		Book.SaveAs(FileName)
	End If
End Sub  

Function FindPattern(TheText, ThePattern)
	RegularExpression.Pattern = ThePattern
	If RegularExpression.Test(TheText) Then
		FindPattern = "True"
	Else
		FindPattern = "False"
	End If
End Function

Function GetPattern(TheText, ThePattern, Flag)
	RegularExpression.Pattern = ThePattern
	Set Matches = RegularExpression.Execute(TheText) 
	For Each Match In Matches
		TheMatch = Match.Value 
		If Flag = "1" Then TheMatch = Mid(TheMatch, 3)
		If Flag = "2" Then TheMatch = Mid(TheMatch, 14)
		If Flag = "3" Then TheMatch = Mid(TheMatch, 11)
	Next
	GetPattern = TheMatch
End Function

Function GetNBTable(HostName)
	NBCommand = "nbtstat -a " & HostName
	WshShell.Run "Cmd.exe /c " & NBCommand &" > C:\Windows\Temp\NBTList.txt", 2,True
	Set TheNBTFile = FileSystem.OpenTextFile("C:\Windows\Temp\NBTList.txt", ForReading, True)
	GetNBTable = TheNBTFile.ReadAll
	TheNBTFile.Close
	FileSystem.DeleteFile("C:\Windows\Temp\NBTList.txt")
End Function

Function GetIPAddress(HostName)
	IPCommand = "ping -n 1 " & HostName
	WshShell.Run "Cmd.exe /c " & IPCommand &" > C:\Windows\Temp\IPList.txt", 2,True
	Set TheIPFile = FileSystem.OpenTextFile("C:\Windows\Temp\IPList.txt", ForReading, True)
	GetIPAddress = TheIPFile.ReadAll
	TheIPFile.Close
	FileSystem.DeleteFile("C:\Windows\Temp\IPList.txt")
End Function

Open in new window

0
 
LVL 7

Expert Comment

by:ashutoshsapre
ID: 35427675
To run the script above you should have MS Excel installed.
0
 
LVL 17

Expert Comment

by:Sajid Shaik M
ID: 35428017
scavange stale records in dns and u'll find the approx record in DNS


try as well as

http://technet.microsoft.com/en-us/sysinternals/bb842062

all the best
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Uncontrolled local administrators groups within any organization pose a huge security risk. Because these groups are locally managed it becomes difficult to audit and maintain them.
After seeing many questions for JRNL_WRAP_ERROR for replication failure, I thought it would be useful to write this article.
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question