Troubleshooting Code 800A0CC1 - Item cannot be found in the collection
Difficult error code to solve. You may need lateral thinking to cure 800A0CC1
Introduction to Code 800A0CC1
Error code, 800A0CC1 occurs when you execute a VBScript.
The Symptoms you get
The script does not execute as you had hoped. Instead. Windows
Scripting host generates a message
box like this picture:
The Cause of Code 800A0CC1
Your VBScript contains an incorrect argument. Note: The clue
Source: ADODB.Recordset.
The Solution
The Windows Scripting Host gives us three useful clues, firstly, look on
Line: 22, do count any remark or empty lines. Secondly, the Char: number
1, is less useful as the error could be anywhere on that line. Thirdly Expected 'Item
not found....' is pointing us to the script problem. This an obscure
error, the problem is that the script is trying to display OU, but OU is not
a valid property of the computer object.
Example of error 800A0CC1 Script
I admit that this is a specialist script in the sense that it has a hard-coded name of the domain.
Check the & OU line.
' VBScript to display the XP machines in your
Active Directory domain
' Guy Thomas February 2004.
' ******************************
Const ADS_SCOPE_SUBTREE = 2
objDom = "cn=computers,DC=cp,DC=com"
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.CommandText = _
"Select Name, Location, operatingSystemVersion from 'LDAP:// cn=computers,DC=cp,DC=com'"
_
& " where objectClass='computer' " _
& " and operatingSystemVersion = '5.1 (2600)'"
objCommand.Properties("Page Size") = 500
objCommand.Properties("Timeout") = 20
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
Wscript.Echo "Computer Name: " & objRecordSet.Fields("Name").Value & VBCr _
& "Version: " & objRecordSet.Fields("operatingSystemVersion").Value & VBCr _ & "OU: " & objRecordSet.Fields("ou").Value objRecordSet.MoveNext
Loop
' End of Script
Corrected Version
With & "OU: " & objRecordSet.Fields("ou").Value removed.
' Computers.vbs ' Example VBScript to display the Computer Objects in your domain ' Guy Thomas February 2004. ' ****************************** Set
objConnection = CreateObject("ADODB.Connection") Set objCommand = CreateObject("ADODB.Command") objConnection.Provider = "ADsDSOObject" objConnection.Open "Active Directory Provider" Set
objCommand.ActiveConnection = objConnection objCommand.CommandText = _ "Select Name, operatingSystemVersion from 'LDAP://dc=cp, dc=com'" _ & " where objectClass='computer' "
objCommand.Properties("Page Size") = 500 objCommand.Properties("Timeout") = 20 objCommand.Properties("Cache Results") = False Set objRecordSet = objCommand.Execute objRecordSet.MoveFirst Do
Until objRecordSet.EOF Wscript.Echo "Computer: " & objRecordSet.Fields("Name").Value & VbCr _ & "Version: " & objRecordSet.Fields("operatingSystemVersion").Value objRecordSet.MoveNext Loop
' End of example VBScript
Try
a different solution, download SolarWinds ipMonitor
Here is my thinking,
ipMonitor will give you valuable data about your network and servers.
This extra information just may unlock the solution to your error code.
One more thing, sometimes when troubleshooting you go around in circles;
therefore if you try a different, but related approach, you may just crack the
problem.
Free Download
of SolarWinds ipMonitor
Their topics and material are ideal for getting you started with VBScript. The
videos are easy to follow and you can control the pace. Try their free demo material and then see if you want to buy the full package.
See more about VB Script Training CD.