Returns a list of all disabled user accounts in the fabrikam.com domain.
Const ADS_UF_ACCOUNTDISABLE = 2Set objConnection = CreateObject("ADODB.Connection")objConnection.Open "Provider=ADsDSOObject;"Set objCommand = CreateObject("ADODB.Command")objCommand.ActiveConnection = objConnectionobjCommand.CommandText = _"<GC://dc=fabrikam,dc=com>;(objectCategory=User)" & _";userAccountControl,distinguishedName;subtree"Set objRecordSet = objCommand.ExecuteintCounter = 0While Not objRecordset.EOFintUAC=objRecordset.Fields("userAccountControl")If intUAC AND ADS_UF_ACCOUNTDISABLE ThenWScript.echo objRecordset.Fields("distinguishedName") & " is disabled"intCounter = intCounter + 1End IfobjRecordset.MoveNextWendWScript.Echo VbCrLf & "A total of " & intCounter & " accounts are disabled."objConnection.Close
This is a VB Script, this can be used by saving the file in .vbs file