Output InformationBy default, this script would not have any output information. However, to illustrate that the script is actually doing something, I implemented a simple WScript.Echo command to echo out the name of the container that was created. Because the OU to be created is held in the variable named oOUname, it was a simple proposition to echo out the contents of the variable, as illustrated in the following code snippetthe problem is the line of code could "lie" to you. If an error occurred, it would still say the OU was created. WScript.Echo("OU " & oOUname & " was created") To forestall this inexactitude, check the err object. If there are no errors, print out the line. If, however, an error occurs, then trap the message. The error line Err.number = "-2147019886" was developed by printing out the error numbers. When it was noticed that -2147019886 always appeared when a duplicate object existed, it was trivial to report this information. This is seen below: If Err.number = 0 Then WScript.Echo(strOUname & " was created") Else If Err.number = "-2147019886" Then WScript.Echo strOUname & " already exists" Else WScript.Echo " error on the play " & Err.Number End If End If
|