/build/static/layout/Breadcrumb_cap_w.png

Domain join script sets static DNS server address instead of DHCP

I am using a join domain and rename post install task from this KACE article:

http://www.kace.com/support/resources/kb/article/How-to-rename-a-computer-and-join-it-to-a-Windows-domain-Image-Deployment

But the join_domain.vbs script sets a static DNS server which it does not remove and therefore causes issues when connecting to a different network (The DNS server address by the way is pulled from the JoinDomain.bat script downloaded in the same package (explained in the KACE article).

My VB scripting is rubbish so does anyone know how I can change the script syntax to pull a DNS server address from DHCP instead of setting it statically?

Syntax:

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)

1 Comment   [ + ] Show comment
  • Can the script be edit to have machine not to register itself in DNS:
    Netsh
    It can be scripted using Netsh
    IPv4:
    netsh interface ipv4 set dnsservers name="Local Network Area" source=dhcp register=none

    IPv6:
    netsh interface ipv6 set dnsservers name="Local Network Area" source=dhcp register=none

    Not sure where it can be add in or tweaked - colleen.murray 6 years ago

Answers (2)

Answer Summary:
Added the following command to the end of the script: netsh interface ip set dns "Local Area Connection" source=dhcp
Posted by: LiamSinton 12 years ago
Senior Yellow Belt
3

I have managed to accomplish this by adding the following command to the end of my JoinDomain.bat script (not that anybody seems interested)

netsh interface ip set dns "Local Area Connection" source=dhcp


Comments:
  • I'm interested and thanks for the help. I had the same issue - InterneToughGuy 11 years ago
  • Perfect... thank you... that worked - binuani 11 years ago
  • Thank you! I've been having this issue also! - tatkinson 9 years ago
Posted by: rzielinski 11 years ago
White Belt
0

I've been having the same problem. Thanks a lot for the post.

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:

Link

Related Links

Post

Related Posts

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ