Returning OU based on Computer object 
Author Message
 Returning OU based on Computer object

I'm looking to write a VBScript that will find a Computer object in the AD
and return the OU in which it is located.  I've driven myself half-mad by
swimming around the MSDN libraries, and was wondering if anyone had already
done something similar in a VBScript already.

Much obliged,

--Ben

--
Ben Gagnon
PC Classroom Operations / OIT
790 W.E.B. DuBois Library
University of Massachusetts, Amherst 01003
(413) 577-0713



Sat, 26 Jun 2004 22:55:53 GMT  
 Returning OU based on Computer object
Hi,
here is some code to check this;

Set objNet = WScript.CreateObject("WScript.Network")
myDomain = "yourdomain"
Computername = objNet.ComputerName
Set myComputer = GetObject("WinNT://"& myDomain&"/"&
ComputerName &",computer")
WScript.Echo myComputer.Division

HIH ,

Bruno

Quote:
>-----Original Message-----
>I'm looking to write a VBScript that will find a Computer
object in the AD
>and return the OU in which it is located.  I've driven
myself half-mad by
>swimming around the MSDN libraries, and was wondering if
anyone had already
>done something similar in a VBScript already.

>Much obliged,

>--Ben

>--
>Ben Gagnon
>PC Classroom Operations / OIT
>790 W.E.B. DuBois Library
>University of Massachusetts, Amherst 01003
>(413) 577-0713

>.



Sun, 27 Jun 2004 00:45:52 GMT  
 Returning OU based on Computer object
object.parent should work in the LDAP:// namespace.

Clarence


Quote:
> I'm looking to write a VBScript that will find a Computer object in the AD
> and return the OU in which it is located.  I've driven myself half-mad by
> swimming around the MSDN libraries, and was wondering if anyone had
already
> done something similar in a VBScript already.

> Much obliged,

> --Ben

> --
> Ben Gagnon
> PC Classroom Operations / OIT
> 790 W.E.B. DuBois Library
> University of Massachusetts, Amherst 01003
> (413) 577-0713




Mon, 28 Jun 2004 08:33:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Returning Computer Name based on Computer Descipription

2. Add Computer Objects to Particular OU?

3. Adding Computer Objects to Particular OU

4. Computers from OU and then IP of those computers

5. Computers from OU and then IP of those computers

6. Newbie-- Mapping Network Drives based on OU

7. Map Drives and Connect Printers based on OU Membership

8. Mapping drive based off of OU and user name

9. Ghost Sysprep XP add computer to domain inside OU

10. Locating a Computers Organizational Unit (OU)

11. Determining which OU a Computer Belongs to at Logon

12. Returning a Users OU - Help

 

 
Powered by phpBB® Forum Software