I have a logon script that I have been using for several years that will perform funtions such as map printers and drives for a computer according to the OU it belongs to.(ex
Select case(OU)
'##############
'Case Ucase("Laptops")
WshNet.AddWindowsPrinterConnection "\\server\printer"
'**************
I am now working in a new domain that has many child OUs named "Laptops" and "Desktops". How can I get the script to read the DistinguishedName of the OU?
Set wshNet = CreateObject("Wscript.network")
Set WshShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Grab the user name
UserString = wshnet.UserName
WinDir = WshShell.ExpandEnvironmentStrings("%WinDir%")
'###################..GET DOMAIN OU's
Set objSysInfo = CreateObject("ADSystemInfo")
''''''''''Set objNewOU = GetObject("LDAP://DC=xx-aaadd,DC=net")
set pc = getObject("LDAP://" & objSysInfo.ComputerName)
set container = getObject(pc.parent)
OU = Mid(container.name,4)
Select case UCase(OU)
'##############
Case Ucase("Laptops")
Wscript.Echo "It's Here IN THE TRC LAPTOPS OU!"
'##############
Case Ucase("Computers")
Wscript.Echo "It's Here IN THE Computers OU!"
end select
Thanks!
Select case(OU)
'##############
'Case Ucase("Laptops")
WshNet.AddWindowsPrinterConnection "\\server\printer"
'**************
I am now working in a new domain that has many child OUs named "Laptops" and "Desktops". How can I get the script to read the DistinguishedName of the OU?
Set wshNet = CreateObject("Wscript.network")
Set WshShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Grab the user name
UserString = wshnet.UserName
WinDir = WshShell.ExpandEnvironmentStrings("%WinDir%")
'###################..GET DOMAIN OU's
Set objSysInfo = CreateObject("ADSystemInfo")
''''''''''Set objNewOU = GetObject("LDAP://DC=xx-aaadd,DC=net")
set pc = getObject("LDAP://" & objSysInfo.ComputerName)
set container = getObject(pc.parent)
OU = Mid(container.name,4)
Select case UCase(OU)
'##############
Case Ucase("Laptops")
Wscript.Echo "It's Here IN THE TRC LAPTOPS OU!"
'##############
Case Ucase("Computers")
Wscript.Echo "It's Here IN THE Computers OU!"
end select
Thanks!