Question Locked

VBScript help, my brain has oozed out of my head.

0 helpful
6 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Ok so I think I'm subconsiously forgetting how, but I have the PC name and I can't remember how to querie AD to get the OU the object is in.

Someone has to know..

6 replies

by jck

set wshnet=createobject("wscript.network")
scomputer=wshnet.computername
set wshnet=nothing

by larryd4

I have the AD name of the PC, and I need to query AD to find out what OU it resides in.

by jck

sComputer = CreateObject("ADSystemInfo").ComputerName
if InStr(sComputer, ",CN=Computers,DC=") ^> 0 Then
sDN="Computers,DC"
Else
sDN = Mid(sComputer, InStr(sComputer, "OU=") + 3)
End If
sOU = Left(sDN, InStr(sDN, ",") - 1)

That should work

by larryd4

sComputer = CreateObject("ADSystemInfo").ComputerName
Thats all I needed! What a brain fart I had...
Thanks..

This discussion is closed to new replies.