Jump to content


  • 0
countdown2008

Move Computer to Specific OU During Build - Based on Hardware type and Computer Name

Question

Hi guys, I am attempting to move a computer (laptop or desktop) to a specific OU as part of my build process.

 

The build goes absolutely fine but it doesn't join the domain and joins to a workgroup.

 

The script which I have been using is detailed here:

 

http://blog-en.netvnext.com/2012/02/osd-automate-domain-ou-name-from.html

 

 

set env = CreateObject("Microsoft.SMS.TSEnvironment")
sComputerName = env("OSDComputerName")
twoChars = UCase(Left(sComputerName,2))
sBuiltOU = "NOT_set!"
If twoChars = "AB" Then
sBuiltOU = "LDAP://OU=AB,OU=Laptops,OU=Computers,DC=DOMAIN,DC=COM"
If twoChars = "CD" Then
sBuiltOU = "LDAP://OU=CD,OU=Laptops,OU=Computers,DC=DOMAIN,DC=COM"
If twoChars = "EF" Then
sBuiltOU = "LDAP://OU=EF,OU=Laptops,OU=Computers,DC=DOMAIN,DC=COM"
env("OSDDomainOUName") = sBuiltOU
Wscript.quit

 

What I basically want to do is get the task sequence to interrogate the device to understand if its a desktop or a laptop and then move it to a specific OU based on the first two characters of the host name and hardware type. I was initially using the IsVM, IsLaptop, IsDesktop vairables but that seemed to be kind of flakey as I was testing in my lab with VMs only. So for the VMs I changed to use WMI query instead.

 

I setup a couple of new task sequence variable steps to help with this process so if it was a laptop run OUMoveLaptop.vbs to get it into the correct OU and the same sort of process for the desktops (with an OUMoveDesktop.vbs script) in the Post Install phase between the Apply Windows Settings and Apply Network Settings steps.

 

I've attached the screenshots of what I have setup and hopefully one of you kind guys can help me out before I launch this server out my office window. :D

 

Thanks in advance...

post-29626-0-58278700-1431359155_thumb.png

post-29626-0-93296100-1431359157_thumb.png

post-29626-0-49032300-1431359159_thumb.png

post-29626-0-38173700-1431359160_thumb.png

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Did you verify if the task sequence variables are set?

 

I think I've actually worked out what was going wrong. When I looked though the log files generated it appeared that the IsVM was set True which is fine as its a VM, but so was the IsDesktop value too when I was building and testing using a VM in my test lab! I removed the IsVM variable step and left in the IsDesktop and IsLaptop and hey presto it worked.

 

I think what must of been happening is that by using both these variables (IsVM and IsDesktop) were tripping one another up in the way that I was using them. Does that make sense?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.