[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 159
  • Last Modified:

Adding workgroup computer (Windows Server 2003 and Windows 2008) to domain using vbscript.

Hi All,

Could you please help me how to change workgroup to domain using vbscript for Windows Server 2003 and Windows Server 2008.
 
These are the below steps which we are manually adding workgroup computer to domain.

1. Right click My Computer and select Properties.

2. Then click Advanced system settings.

3. Go to Computer Name tab and click change.

4. Then select Domain and enter the Domain name.

5. Once the Domain is added, then click to More in the Computer Name tab and edit Primary DNS suffix of this computer.

6. Uncheck (Disable) Change primary DNS suffix when domain membership changes.

7. Reboot the system.

Could you please anyone to create a script for me as I need to manually add 76 servers

Any assistance could offer would be greatly appreciated.

Attached screenshot for examples.
 1 2
0
jashir101
Asked:
jashir101
  • 3
  • 2
  • 2
2 Solutions
 
Neil RussellTechnical Development LeadCommented:
Dont need a script, use NETDOM.EXE

http://www.networknet.nl/apps/wp/archives/23
0
 
pritamduttCommented:
It is possible to use NETDOM utility to join to Domain using command line.

You can visit following link to learn more.

http://support.microsoft.com/kb/150493

Hope this helps
0
 
pritamduttCommented:
Alternatively you can use WMI in VBScript
Const JOIN_DOMAIN = 1
Const ACCT_CREATE = 2
 
strDomain = "DOMAIN_NAME"
strUser = "USER_NAME"
strPassword = "PASSWORD"
strOU = "ou=COMPUTERS,ou=TESTOU,dc=COMPANY,dc=COM"
 
Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName
 
Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & strComputer & "'")

objComputer.JoinDomainOrWorkGroup strDomain, strPassword, strDomain & "\" & strUser, strOU, JOIN_DOMAIN + ACCT_CREATE

Open in new window


Where
strDomain - domain name
strUser - user id with rights to create a computer object
strPassword - the password for the user id specified in strUser
strOU - the Active Directory OU where the Computer object will be created, in FQDN format
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
jashir101Author Commented:
This is not what im looking for. I have clearly mentioned the details in the title and question.

Can u please tell me what i have to give in OU and make a script it will prompt to ask which domain is to be added as we are using 3 domains.

Also i want to uncheck Change primary DNS suffix when domain membership changes

So please help me.
0
 
Neil RussellTechnical Development LeadCommented:
CLEARLY MENTIONED?

Where was the bit about 3 domain?

I find you manner rude and as far as I am concerened you can go find your own script.  Were to help and offer the best advice based on THE QUESTION DETAILS.

0
 
pritamduttCommented:
You could add following reference code to ask the user and apply applicable Domain

Set objStdOut = WScript.StdOut
objStdOut.Write "Which Domain do you want to connect to?" & vbCRLF
objStdOut.Write "1. domain 1" & vbCRLF
objStdOut.Write "2. domain 2" & vbCRLF
userOption = Wscript.StdIn.ReadLine
if userOption = 1 Then
	strOU = "ou=COMPUTERS,ou=TESTOU,dc=domain1,dc=COM"
ENd If
if userOption = 2 Then
	strOU = "ou=COMPUTERS,ou=TESTOU,dc=domain2,dc=COM"
ENd If

if userOption = 3 Then
	strOU = "ou=COMPUTERS,ou=TESTOU,dc=domain1,dc=COM"
ENd If
if userOption = 4 Then
	strOU = "ou=COMPUTERS,ou=TESTOU,dc=domain1,dc=COM"
ENd If

Open in new window


Hope this helps

For list of various Join options visit : http://msdn.microsoft.com/en-us/library/windows/desktop/aa392154(v=vs.85).aspx
0
 
jashir101Author Commented:
I am not getting proper solution. Please help me on this.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now