Possible AD query/dropdown list to select OU during deployment?
Hi all,
We are currently in a situation where we have multiple locations with RSA's and every location has three different OU's for different systems in the Active Directory.
With the domain join postinstall script we can put computers in the correct OU, but for every different OU there is a different postinstall script, and thus a different deployment.
This has worked fine up to the point we want to create a new system image and deployment, as this is forcing us to make over thirty different deployments, one with each a different domain/OU join postinstall script.
We want to know if there is a way to get a dropdown list of all the OU's to select during the deployment and then have the computer populate that OU. Powershell or VBS?
Thanks in advance.
Answers (1)
You can pre-create the machines in AD in the OU where you want them. Join them to the domain with this script. The trick is the user doing the joining needs to modify the existing AD machine objects to update them. Give no other abilities in AD for better security. We do this for our 2000+ academic machines. We re-image every year and this has always worked for here. Our Acad images are 100% hands off after starting them.
Const JOIN_DOMAIN = 1
Const ACCT_CREATE = 2
Const ACCT_DELETE = 4
Const WIN9X_UPGRADE = 16
Const DOMAIN_JOIN_IF_JOINED = 32
Const JOIN_UNSECURE = 64
Const MACHINE_PASSWORD_PASSED = 128
Const DEFERRED_SPN_SET = 256
Const INSTALL_INVOCATION = 262144
If WScript.Arguments.Count < 3 or WScript.Arguments.Count > 4 Then
WScript.Quit
Else
strDomain = WScript.Arguments.Item(0)
strUser = WScript.Arguments.Item(1)
strPassword = WScript.Arguments.Item(2)
'set DNS IP address
If WScript.Arguments.Count = 4 Then
strDNSIP = WScript.Arguments.Item(3)
Set objShell = CreateObject("WScript.shell")
objShell.Run "netsh int ip set dns ""local area connection"" static "& _
strDNSIP &" primary",0,0
End If
End If
Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName
Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & _
strComputer & _
"\root\cimv2:Win32_ComputerSystem.Name='" _
& strComputer & "'")
ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _
strPassword, _
strDomain & "\" & strUser, _
NULL, _
JOIN_DOMAIN+ACCT_CREATE)