Sunday, March 25, 2012

Domain Join Script

As per one of the requirement in recent activity at Global IT Company, we have got the script which we can use to join a machine to domain and then restart the machine.

  • For Windows XP just need to run the script.
  • For Windows 7 we need to run CMD as administrator and then run the script.


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
strDomain = "Domain Name"
strPassword = "Password"
strUser = "Admiistrator"
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)
Dim objShell
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run "C:\WINDOWS\system32\shutdown.exe -r -t 0"
 

1 comment:

Azure Policy support for remediating tags for existing resources

Use Azure policy to remediate tags for existing resources. https://azure.microsoft.com/en-us/updates/azure-provides-at-scale-tags-managem...