Windows Vista Forums

80005000 Error trap

  1. #1


    Dave Susemiehl Guest

    80005000 Error trap

    Hi, I can muddle through scripting ok most of the time but I'm not sure how
    to handle this.

    So here's my dilemma, I want to use a text file for the OU's and Groups to
    create in the OU's. I read them into an array ok so I have them available
    but obviously each OU contains multiple groups. If I just cycle through the
    Array Creating the OU's I will quickly run into an already exists error. I
    couldn't find a good way to do an if exists on OU's so I decided to try to
    get the OU and if it errors the script would create the ou. The nice simple
    GET line looks something like this:

    Set mkOU = GetObject("LDAP://OU=" & arrOU(0) & ",OU=parentOU," & DomainPath)
    ---This line gets the desired results

    And then do an error trap so that if the 80005000 error is encounter It
    creates the OU.

    Any help would be appreciated.



      My System SpecsSystem Spec

  2. #2


    Richard Mueller [MVP] Guest

    Re: 80005000 Error trap


    "Dave Susemiehl" <Dave Susemiehl@xxxxxx> wrote in message
    news:1F154E09-C841-43D7-A182-D17A802B050B@xxxxxx

    > Hi, I can muddle through scripting ok most of the time but I'm not sure
    > how
    > to handle this.
    >
    > So here's my dilemma, I want to use a text file for the OU's and Groups to
    > create in the OU's. I read them into an array ok so I have them available
    > but obviously each OU contains multiple groups. If I just cycle through
    > the
    > Array Creating the OU's I will quickly run into an already exists error.
    > I
    > couldn't find a good way to do an if exists on OU's so I decided to try to
    > get the OU and if it errors the script would create the ou. The nice
    > simple
    > GET line looks something like this:
    >
    > Set mkOU = GetObject("LDAP://OU=" & arrOU(0) & ",OU=parentOU," &
    > DomainPath)
    > ---This line gets the desired results
    >
    > And then do an error trap so that if the 80005000 error is encounter It
    > creates the OU.
    >
    > Any help would be appreciated.
    >
    Use "On Error Resume Next" to suppress normal error handling (which aborts
    the script). Then you can test the Err object for error number and
    description. Use "On Error GoTo 0" to restore normal error handling (this
    also clears the Err object). For example:
    ========
    On Error Resume Next
    Set mkOU = GetObject("LDAP://ou=" arrOU(0) & ",ou=parentOU," & DomainPath)
    If (Err.Number <> 0) Then
    ' Error raised attempting to bind the OU.
    ' Display error information (optional).
    Wscript.Echo "Error binding to OU " & arrOU(0)
    Wscript.Echo "Error Number: " & Err.Number
    Wscript.Echo "Description: " & Err.Description
    Wscript.Echo "Source: " & Err.Source
    On Error GoTo 0
    ' Create the OU.
    ' ...
    Else
    On Error GoTo 0
    ' The OU must already exist
    End If
    =========
    If you know the specific error number you want to trap, you can test for
    that. However, Err.Number will be decimal, while 80005000 is hex, so you
    will need to convert. Best to test and see what Err.Number returns (some are
    negative). I find Err.Number is -2147016656 when I attempt to bind to a
    non-existent OU. If I have an invalid character (invald DN format) I
    get -2147016654. Might be best just to test if Err.Number is non-zero.

    --
    Richard Mueller
    MVP Directory Services
    Hilltop Lab - http://www.rlmueller.net
    --



      My System SpecsSystem Spec

80005000 Error trap

Similar Threads
Thread Forum
Vbscript unable to trap error into excel
Hi Guys, I am trying to grab some information about a list of servers into excel files, which works fine. What i am unable to do is trap the...
VB Script
Trap an Error from an EXE
Hi, I am using PSinfo.exe to do a software inventory on a list of machines. my command looks like this: PS Scripts:\> $psinfoOutput =...
PowerShell
Ping error trap?
Hi guys, I've been looking for a way to ping a range of servers. So far so good, but the script ends with a nasty error whenever a server is...
PowerShell
why cannot Trap catch error
hi I have below statement in my code but for some reason the trap is not catching the error. Any reason why ?? function CheckFolder() { trap...
PowerShell
How to get more information about the error from trap statement
Hi, Is there any way we can get more information from a Trap statement about the error that has just occured. Like the Line number where the...
PowerShell
Script Error: 0x80005000, Code: 80005000, Source: (null)
Hi, I'm running this script on Windows 2008 domain from Exchange 2003 server (all DC's are 2008 core - no GUI). I copied a sript that worked in...
VB Script
How to trap this error in PowerShell
this errorhandling drives me nuts, can't figure this one out : as well continue,break as return do not work : how do I trap this the right way,...
PowerShell