RE: "Dead" Machine Accounts

From: Craig Landis [MSFT] (clandis_at_online.microsoft.com)
Date: 03/09/04


Date: Tue, 9 Mar 2004 14:11:05 -0800

Also, here is a script that can help with this -

'Script will output the machine account that have not changed
'its machine account password in the last 180 days.
'You can reduce this number by changing 15552000 which is
'86400(number seconds in the day) * 180(days). Every machine changes
'its machine account every 7 days for NT4 and 30 days for W2K
'Execute the script using cscript scriptname

Dim Container
Dim TargetDomain
Dim Member
Dim Computer
Dim fso
Dim tf

Set fso = createobject("Scripting.FileSystemObject")
Set tf = fso.createtextfile("C:\oldaccts.txt",TRUE)
TargetDomain = "Net Bios Name" 'Change this to the netbios name of the domain
Set Container = GetObject("WinNT://" & TargetDomain)
Container.Filter = Array("Computer")
For Each Member In Container
Set Computer = GetObject("WinNT://" & TargetDomain & "/" & Member.Name & "$,user")
If Computer.Get("PasswordAge") > 1 Then '15552000 is 180 days=(15552000(seconds)\86400(Seconds in 24hrs)
tf.WriteLine Computer.ADsPath & " " & (Computer.Get("PasswordAge")\86400) & "Days Old"
End If
Next

Craig Landis [MSFT]
clandis@online.microsoft.com

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm



Relevant Pages

  • RE: export user accounts from NT 4.0 domain
    ... ATTENTION THE SCRIPT MUST BE RUNNED FROM A COMPUTER WHERE EXCEL IS ... from the information in a Microsoft Excel spreadsheet. ... Dim strLast, strFirst, strMiddle, strPW, intRow, intCol ... On Error GoTo 0 ...
    (microsoft.public.windows.server.scripting)
  • Re: Password Expire
    ... We have one fron end Edge server in our DMZ which passes email onto two ... I used to schedule a script to run every 24 hours on my Exchange 2003 ... Dim fso, txtarray, BodyText ... Call ProcessFolder (objContainer, numDays) ...
    (microsoft.public.exchange.admin)
  • Re: LDAP query information
    ... a "Dim" statement. ... execution of the script. ... ' Filter on computer object. ... ' Construct LDAP syntax query. ...
    (microsoft.public.windows.server.scripting)
  • Re: ADSI Problem
    ... Right I've got the script working now with my ASP applications by passing the ... If you are doing forms authentication using ADSI (which it sounds like you ... Restarting IIS usually gets it working again. ... Dim strUserName ...
    (microsoft.public.windows.server.active_directory)
  • Re: Script: Remote shutdown of all domain computers
    ... When trying to run the script from a XP workstation, where i am logged in as ... Dim strBase, strFilter, strAttributes, strQuery, objRecordSet ... 2000 or above and allow shutdown, ... Public Function AllComputersAs String() ...
    (microsoft.public.windows.server.scripting)

Loading