![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | Re: 80005000 Error trap "Dave Susemiehl" <Dave Susemiehl@xxxxxx> wrote in message news:1F154E09-C841-43D7-A182-D17A802B050B@xxxxxx Quote: > 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. > 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 Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Trap an Error from an EXE | PowerShell | |||
| Ping error trap? | PowerShell | |||
| why cannot Trap catch error | PowerShell | |||
| Script Error: 0x80005000, Code: 80005000, Source: (null) | VB Script | |||
| How to trap this error in PowerShell | PowerShell | |||