VBScript help, my brain has oozed out of my head.
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..
Desktop
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..
by larryd4 Accepted solution
by jck Accepted solution
set wshnet=createobject("wscript.network")
scomputer=wshnet.computername
set wshnet=nothing
by larryd4 Accepted solution
by jck Accepted solution
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
This discussion is closed to new replies.
Sort by Trending