Jump to content
Sign in to follow this  

Help on converting a vbs script

Recommended Posts


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))

Share this post

Link to post
Share on other sites

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")

$aProperties = _AD_GetObjectProperties($var & "$", "distinguishedName")
MsgBox(0, "", $aProperties[1][1])

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this