Jump to content


Kingen

OSD Join certain domain based on the deafultgateway the computers on?

Recommended Posts

I am looking for a setting in my TS were it puts the computer in a certain domain depending on what gateway ip the computer has.

Like Domain A always have 192.168.40.1 and

Domain B always have 192.168.50.1

 

Is there any option to make computers that have 40.1 join domain A and 50.1 to join B?

Share this post


Link to post
Share on other sites

If you want t use a VB Script, you can just pull the first 3 octects out of the IP. The assigne the domain to the Task Sequence Variable for the domain. I believe this to be OSDJOINDOMAINNAME, but someone may correct me on that - you can always have the %OSDJOINDOMAINNAME% set in the unattend.xml to ensure it will assign correctly. You may be able to do the same with the gateway, but I'm not sure of the WMI object to look for.

 

I have done it this way before:

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

'pulls IP address and trims the first 3 octets
Set colAdapters = objWMIService.ExecQuery _
   ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled=True")
For Each objAdapter in colAdapters
   For Each strAddress in objAdapter.IPAddress
    arrOctets = Split(strAddress, ".")
    If arrOctets(0) <> "" Then
	    strSubnet = arrOctets(0) & "." & arrOctets(1) & "." & arrOctets(2)
	    x = 1
	    Exit For
    End If
    If x = 1 Then
	    Exit For
    End If
   Next
Next

'Displays first 3 octects - you can remove this line
MsgBox strSubnet


Select Case strSubnet
   Case "192.168.40"
	    strDomain = "DomainA"
   Case "192.168.50"
	    strDomain = "DomainB"
End Select

'sets the Task Sequence Variable for the domain
Set oTaskSequence = CreateObject ("Microsoft.SMS.TSEnvironment")
oTaskSequence("OSDJOINDOMAINNAME")= strSubnet

Share this post


Link to post
Share on other sites

Scratch that, this one should do it. Again, double check the last bit for adding the TS variable.

 

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colAdapters = objWMIService.ExecQuery _
   ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled=True")
For Each objAdapter in colAdapters
   For Each strGWAddress in objAdapter.DefaultIPGateway
   MsgBox strGWAddress
Next
Next

Select Case strGWAddress
   Case "192.168.40.1"
	    strDomain = "DomainA"
   Case "192.168.50.1"
	    strDomain = "DomainB"
End Select
Set oTaskSequence = CreateObject ("Microsoft.SMS.TSEnvironment")
oTaskSequence("OSDJOINDOMAINNAME")= strDomain

Share this post


Link to post
Share on other sites

Scratch that, this one should do it. Again, double check the last bit for adding the TS variable.

 

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colAdapters = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled=True")
For Each objAdapter in colAdapters
For Each strGWAddress in objAdapter.DefaultIPGateway
MsgBox strGWAddress
Next
Next

Select Case strGWAddress
 Case "192.168.40.1"
	 strDomain = "DomainA"
 Case "192.168.50.1"
	 strDomain = "DomainB"
End Select
Set oTaskSequence = CreateObject ("Microsoft.SMS.TSEnvironment")
oTaskSequence("OSDJOINDOMAINNAME")= strDomain

 

Whre should i put it? Here:

http://www.ladda-upp.com/bilder-a/thumbs/large/aaasda2asdds-24.png

?

Share this post


Link to post
Share on other sites

I guess your previous issue was down to the last 2 lines where it sets the variables. I've just not done it since SMS 2003, so I'm not sure what I might be missing. If could be just this at the top of the script.

 

Dim oTaskSequence, strDomain, strGWAddress

 

I'm not a VBS guru, I've just been stealing excerpts form other scripts over the years.

Share this post


Link to post
Share on other sites

Try this, I've no idea if it will work, but from what I've read it should:

Add a Task Sequence Variable to the sequence

 

In the Properties tab:

Add OSDJOINDOMAINNAME into the Task Sequence Variable Field, then add DomainA into the Value field

 

In the Options tab:

In the Add Condition/WMIQuery section. Leave the WMI Namespace with "root\cimv2"

Select * From Win32_NetworkAdapterConfiguration Where DefaultIPGateway="192.168.40.1"

 

Creat a new sequence for the Domain B using the same process, but change the entries accordingly.

 

Let me know how it goes.

Con

Share this post


Link to post
Share on other sites

...alternatively instead of adding a Task Sequence Variable, you could just add the condition to the "Join Domain or Workgroup" sequence from the General section. That would be much easier as you can add the join domain username and password info.

 

In the SMS days I had to script all this, it's nice to see that it's all included in SCCM.

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
Reply to this topic...

×   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.