I need to query AD, given a DN, for disabled computers. I am currently querying for other information such as the computer name and the groups that it is a member of. Here is some of the code that I am working with:
Do Until inputFile.AtEndOfStreamTargetDN = inputFile.ReadLine 'each line from the input file contains a DN to be queried' Setup PC Query string using the DN from the input text file and computer/DN parametersstrPCQuery = TargetDN & ";(objectCategory=computer)" & ";distinguishedName,name;subtree"Set objConnection = CreateObject("ADODB.Connection")Set objCommand = CreateObject("ADODB.Command")objConnection.Open "Provider=ADsDSOObject;"objCommand.ActiveConnection = objConnectionobjCommand.CommandText = strPCQueryobjCommand.Properties("Page Size") = 1000Set objRecordSet = objCommand.Execute
Do Until objRecordSet.EOF strComputerName = objRecordSet.Fields("Name").Value strFullDN = objRecordSet.Fields("distinguishedName").Value Set objComputer = GetObject("LDAP://" & strFullDN) Set colGroups = objComputer.Groups 'OUTPUT COMPUTER NAME: outputFile.Write(strComputerName & ";")
...
I'm basically looking to be able to output "enabled" or "disabled" depending on what the status is of the computer.
Thanks!
Query AD for Disabled Computers
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.