Jump to content

Recommended Posts

Posted

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))
  • Moderators
Posted (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 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!

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...