Get the Disabled Users from Active Directory vbs script

Useful little script to output all disabled users in an Active Directory domain or OU. Simply open Notepad, copy and paste the following, and then save as a *.vbs file. Remember to replace the domain and OU name as needed.

On Error Resume Next

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile("output1.txt", True)

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"

objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000

objCommand.CommandText = _
    ";(&(objectCategory=User)" & _
Set objRecordSet = objCommand.Execute

Do Until objRecordSet.EOF
    objFile.WriteLine objRecordSet.Fields("Name").Value