|
|
|||||||
I am trying to determine what OU a computer is in. using the UDF Call "Incontainer.udf" Code: $rc = InContainer("OU=ComputerName,OU=Site,OU=BU,DC=us,DC=guess,DC=com", "Computer") I am getting the error code Script error : expected expression ! $Name2 = TranslateName (3, "", 3, $Name1, 1) Any Idea? I have both the InContainer.udf and TranslateName.udf functions in the directory as the script. |
||||||||
|
|
|||||||
The UDF returns an array and KiX cannot take an array directed to the console. Try: $rc = InContainer("OU=ComputerName,OU=Site,OU=BU,DC=us,DC=guess,DC=com", "Computer")[0] |
||||||||
|
|
|||||||
I still got the same error. It seems to be coming from the translate code. If you want I can upload it but I took it directly off the udf library. |
||||||||
|
|
|||||||
did you read the dependencies of the udf, you need the TranslateName() udf as well Quote: |
||||||||
|
|
|||||||
Thanks. I assumed that the incontainer was calling translatename. However I am now getting object is Not a member of this container or a chile of this container. However I know it is. Is it possible I am missing something in the syntax. Code: ;$rc = InContainer("OU=ComputerName,OU=Site,OU=BU,DC=us,DC=guess,DC=com", "Computer") |
||||||||
|
|
|||||||
How can we know if you have the syntax right if you obfuscate the DN with bogus example? What is "OU=ComputerName" supposed to represent? Do you really have a computer in an OU that that is called "computername"? |
||||||||
|
|
|||||||
WHat I originally said about the UDF returning an array still stands. You cannot direct $rc to the console. |
||||||||
|
|
|||||||
When exectued the following appears object is NOT a member of this container or a child of this container However I have verified that computer lta0210896a exist in an ou within the NTX ou Am I listing the computer name correctly? Code:
|
||||||||
|
|
|||||||
You are using the UDF wrong. @WKSTA is not an OU is it? I mean, you don't have an OU named after every computer do you? $rc= InContainer("OU=NTX,DC=us,DC=dseg,DC=com","Computer") |
||||||||
|
|
|||||||
If you post your code that is failing, I would be happy to review it. Be sure to use the Instant UBB code (Code) to properly format the posted code. |
||||||||
|
|
|||||||
The computer name is implied. You should not pass it as a parm. If you need a version of Howard's UDF that takes the computername as a 3rd parm, I modified the UDF to work in an admin script. |
||||||||
|
|
|||||||
Thanks Les. Thats It I didn't read the udf paramaters properly. |
||||||||
|
|
|||||||
Dazzling... Simple question, I hope. I've browsed the board and all examples I see start from the principle that I ask "Is this user in OU xxx?" and I get a Yes or a No. Is there a way to just get a string returned that represents the OU the user is in? like a sort of GetOU("%USERNAME%") so to speak? My thanks, Jaap. |
||||||||
|
|
|||||||
No, but the TranslateName() UDF with a simple Split() or two would do it. It has been discussed before. |