Jump to content

Recommended Posts

Posted

Does anyone know of a way to automatically move or add a new computer to a specific OU during sysprep once a computer has been sysprep'd? Instead of doing it manually ising AD Users and Computers.

 

At the moment all i have to when sysprep runs is type a computer name. The rest automatically joins it to a domain and sets the settings etc.

 

It would be nice so that it would move to the correct OU then run gpupdate so it picks up the correct GPOs on boot up.

 

Thanks

Posted

On Error Resume Next

 

Const ADS_SCOPE_SUBTREE = 2

 

Set WshNetwork = WScript.CreateObject("WScript.Network")

 

set objOU = GetObject("LDAP://ou=Maxdata desktops,ou=ICT SUITES,ou=Computers,ou=school name,dc=curriculum,dc=local")

 

Set objConnection = CreateObject("ADODB.Connection")

Set objCommand = CreateObject("ADODB.Command")

objConnection.Provider = "ADsDSOObject"

objConnection.Open "Active Directory Provider"

Set objCommand.ActiveConnection = objConnection

 

objCommand.Properties("Page Size") = 1000

objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

 

objCommand.CommandText = _

"SELECT ADsPath FROM 'LDAP://dc=curriculum,dc=local' WHERE objectCategory='computer' " & _

"AND Name='" & wshNetwork.ComputerName & "'"

 

 

Wscript.Echo " " & wshNetwork.ComputerName

 

Set objRecordSet = objCommand.Execute

objRecordSet.MoveFirst

 

Do Until objRecordSet.EOF

strADsPath = objRecordSet.Fields("ADsPath").Value

objOU.MoveHere strADsPath, vbNullString

objRecordSet.MoveNext

 

Loop

  • 8 months later...
Posted

Back in the day before altiris I used Workstation Name Changer - wsnames.exe to get my machines setup.

 

But yeah if you have a vbs script and want it to run at first start up and disappear put a path to script in registry under local machine in 'run once'.

 

Normally I have the script sit on c: drive 'wsnames' or in Windows directory.

 

Cheers,

 

Phil

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...