Code Error 800A0CC1 – Item cannot be found in the collection

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.Code 800A0CC1 - Item cannot be found in the collection

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 2010.
‘ ******************************
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 2010.
‘ ******************************
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

 

 

See More Windows Update Error Codes 8004 Series

Error 800A101A8 Object Required   •Error 800A0046   •Error 800A10AD   •Error 800A000D

Error 80048820   •Error 800A0401   •Review of SolarWinds Permissions Monitor

Error 80040E14   • Error 800A03EA   • Error 800A0408   • Error 800A03EE

Solarwinds Free WMI MonitorGuy Recommends: WMI Monitor and It’s Free!

Windows Management Instrumentation (WMI) is one of the hidden treasures of Microsoft operating systems.  Fortunately, SolarWinds have created the WMI Monitor so that you can examine these gems of performance information for free.  Take the guess work out of which WMI counters to use for applications like Microsoft Active Directory, SQL or Exchange Server.

Download your free copy of WMI Monitor


Do you need additional help?

Give something back?

Would you like to help others?  If you have a good example of this error, then please email me, I will publish it with a credit to you:

 

If you like this page then please share it with your friends