公司內部大約有160台電腦 要把這些PC從A網域退之後加到B網域,印象中好像有聽過可以寫批次來執行這動作!!!!不知道各位大神是否可以提供範本或是寫法呢>?
'Join Doamin VB Examples
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 = "FABRIKAM"
strPassword = "ls4k5ywA"
strUser = "shenalan"
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)
'unjoin method
uint32 UnjoinDomainOrWorkgroup(
[in] string Password,
[in] string UserName,
[in] uint32 FUnjoinOptions = 0
);
還是用 vbs 比較好
join domain
http://www.vbsedit.com/scripts/ad/computer/scr_5.asp
unjoin domain
http://www.vbsedit.com/scripts/ad/computer/scr_18.asp
先退出舊網域在加入新網域
程式碼
https://www.dropbox.com/s/110kcep3syihmv6/rejoin.txt?dl=0
請善用 User Profile Wizard 工具, 減少 IT 人員的工作負擔, 準時下班:
User Profile Wizard 3.9