我想使用 VB 在 AD 中搜索禁用帐户(超过 90 天并删除他们的主目录。以下脚本可以正常工作但不能递归:(
任何人都可以帮助使其工作吗?他将高度赞赏任何帮助:)
Option Explicit
Dim objOU, objUser, objFSO, strHomeDirectory, objTextFile
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objOU = GetObject("LDAP://OU=users,DC=corp,DC=contoso,DC=com")
objOU.Filter = Array("user")
For Each objUser In objOU
if ( objuser.useraccountcontrol = 514 Or objuser.useraccountcontrol = 66050 ) And DateDiff("d", objUser.WhenChanged, Now) > 90 Then
' Retrieve home directory.
strHomeDirectory = objUser.homeDirectory
' Replace %username% with value of sAMAccountName attribute.
strHomeDirectory = Replace(strHomeDirectory, "%username%", objUser.sAMAccountName)
' Delete the folder.
objFSO.DeleteFolder strHomeDirectory
else
wscript.sleep 100
End If
Next