• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 372
  • Last Modified:

how to update fix and refresh computers in ou group on active directory

i have server 2003 as dc and i see inside active directory users and computers in ou wich inside i have all the computer name that the list don`t true ,i have computer that dont exist anymore so how i can refresh this list and correct it to take all the update computer that exist on the network?
0
buildingit
Asked:
buildingit
2 Solutions
 
ACollyerCommented:
You could use something like dsquery to obtain a list of workstations that have been inactive for X number of weeks:

dsquery computer OU=MyOU,DC=MyDomain,DC=local -inactive 2

This will return a list of computers (including their DNs) that have been inactive for 2 weeks. You could either pipe this output into something like dsrm to delete them, or manually look through the list and delete them yourself. I strongly recommend the latter.
0
 
Donald StewartNetwork AdministratorCommented:
Here's a script that prompts you for the domain name and then you specify the cutoff age for computers to get deleted.

rem Delete Old computer accounts from AC
Dim OutPutFile
Dim FileSystem
 
Set FileSystem = WScript.CreateObject("Scripting.FileSystemObject")
Set OutPutFile = FileSystem.CreateTextFile("bad_comp_names.txt", True)
 
On Error Resume Next
 
DomainString=Inputbox("Enter the domain name","Check Active Computers","DomainName")
 
if DomainString="" then
wscript.echo "No domain specified or script cancelled."
wscript.quit
end if
 
numDays=InputBox("What is the number of days to use as a cutoff for" & _
"Active Computer Accounts?","Check Active Computers","XX")
 
if numDays="" then
wscript.echo "No cutoff date specified or script cancelled."
wscript.quit
end if
 
Set DomainObj = GetObject("WinNT://"&DomainString)
 
if err.number<>0 then
wscript.echo "Error connecting to " & DomainString
wscript.quit
end if
 
DomainObj.Filter = Array("computer")
Wscript.echo "Computer Accounts in " & DomainString & " older than " & numDays & " days"
For each Computer in DomainObj
Set Account = GetObject("WinNT://" & DomainString & "/" & Computer.Name & "$")
RefreshTime = FormatNumber((Account.get("PasswordAge"))/86400,0)
If CInt(RefreshTime) >= CInt(numDays) Then
'wscript.echo "**DELETE** " & Computer.Name & " Password Age is " & RefreshTime & " days."
OutPutFile.WriteLine Computer.Name
'Call DomainObj.Delete("Computer", Computer.Name)
End If
Next
 
 
OutPutFile.Close
Set FileSystem = Nothing
Set oContainer = Nothing
set DomainObj=Nothing
set Shell=Nothing
Wscript.quit

Open in new window

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now