I would use adsi to do this
for example Don Jones script to locate and disable user accounts from
Managing Windows with WMI and VBScript is like this
Script start
Dim dDate
Dim oUser
Dim oObject
Dim oGroup
Dim iFlags
Dim iDiff
Dim iResult
Const UF_ACCOUNTDISABLE = &H0002
'Set this to TRUE to enable Logging only mode -
'no changes will be made
CONST LogOnly = TRUE
'Point to oObject containing users to check
Set oGroup = GetObject("WinNT://MYDOMAINCONTROLLER/Domain Users")
On error resume next
For each oObject in oGroup.Members
'Find all User Objects Within Domain Users group
'(ignore machine accounts)
If (oObject.Class = "User") And _
(InStr(oObject.Name, "$") = 0) Then
Set oUser = GetObject(oObject.ADsPath)
End If
dDate = oUser.get("LastLogin")
dDate = Left(dDate,8)
dDate = CDate(dDate)
'find difference in weeks between then and now
iDiff = DateDiff("ww", dDate, Now)
'if 6 weeks or more then disable the account
If iDiff >= 6 Then
iFlags = oUser.Get("UserFlags")
End If
If (iFlags AND UF_ACCOUNTDISABLE) = 0 Then
' Only disable accounts if LogOnly set to FALSE
If LogOnly = False Then
oUser.Put "UserFlags", iFlags OR UF_ACCOUNTDISABLE
oUser.SetInfo
End if
sName = oUser.Name
iResult = Log(sName,iDiff)
End If
Next
Set oGroup = Nothing
MsgBox "All Done!"
Function Log(sUser,sDate)
'Constant for Log file path
CONST StrLogFile = "C:\UserMgr1.txt"
Set oFS = CreateObject("Scripting.FileSystemObject")
Set oTS = oFS.OpenTextFile(strLogFile, 8, True)
oTS.WriteLine("Account:" & vbTab & sUser & vbTab & _
"Inactive for:" & vbTab & sDate & vbTab & "Weeks" & _
vbTab & "Disabled on:" & vbTab & Date & vbTab & "at:" & _
vbTab & Time)
oTS.Close
Set oFS = Nothing
Set oTS = Nothing
End Function
script end
adsi scriptomatic details here
http://www.microsoft.com/technet/community/scriptcenter/tools/admatic.mspx
hth
regards steve