BadGrim Posted February 28, 2013 Share Posted February 28, 2013 Hello all, Im trying to convert a vbs script I have. and I seems to be missing something. not sure what. the intent, is to return the OU of a computer object, so I can use it later in the script: Set objSysInfo = CreateObject("ADSystemInfo") strComputer = objSysInfo.ComputerName Set objComputer = GetObject("LDAP://" & strComputer) arrOUs = Split(objComputer.Parent, ",") arrMainOU = Split(arrOUs(1), "=") Wscript.Echo arrMainOU(1) AutoitCode that fails. $objSysInfo = ObjCreate("ADSystemInfo") $strComputer = $objSysInfo.ComputerName $objComputer = ObjGet("LDAP://" & $strComputer) MsgBox(4096, "", $objComputer.Parent) $arrOUs = StringSplit($objComputer.Parent, ",") MsgBox(4096, "", $arrOUs) $arrMainOU = StringSplit($arrOUs(1), "=") ConsoleWrite ($arrMainOU(1)) Link to comment Share on other sites More sharing options...
GMK Posted February 28, 2013 Share Posted February 28, 2013 Try this:#include <Array.au3> $oSysInfo = ObjCreate("ADSystemInfo") $sComputer = $oSysInfo.ComputerName $oComputer = ObjGet("LDAP://" & $sComputer) MsgBox(4096, "", $oComputer.Parent) $aOUs = StringSplit($oComputer.Parent, ",") _ArrayDisplay($aOUs) $aMainOU = StringSplit($aOUs[1], "=") ConsoleWrite ($aMainOU[1] & @CRLF) Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted February 28, 2013 Moderators Share Posted February 28, 2013 (edited) Or you could use Water's great AD UDF, which will do just about anything you need in A.D. (http://www.autoitscript.com/forum/index.php?showtopic=110614). This is what I use for checking a computer's container:#include <AD.au3> $var = InputBox("Find PC in OU", "Please enter the PC Name") _AD_Open() $aProperties = _AD_GetObjectProperties($var & "$", "distinguishedName") MsgBox(0, "", $aProperties[1][1]) _AD_Close() Edited February 28, 2013 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now