作成 2010.01.05
更新 2010.01.05
更新 2010.01.05
ドメインに参加させる
<job id="join domain"> <comment></comment> <object id="wmiLocator" progid="WbemScripting.SWbemLocator" /> <object id="WshShell" progid="WScript.Shell" /> <script language="VBScript"> Option Explicit Const DOMAIN_NAME = "MYDOMAIN" Const DOMAIN_ADMINISTRATOR = "root" Const DOMAIN_PASSWORD = "p@ssw0rd" Const JOIN_DOMAIN = 1 Const ACCT_CREATE = 2 Const evError = 1 Const evInfomation = 4 Dim wmiService Dim pcInstance Dim pcEnumerator Dim tmpReturnCode Set wmiService = wmiLocator.ConnectServer Set pcInstance = wmiService.ExecQuery ("Select * From Win32_ComputerSystem") For Each pcEnumerator In pcInstance ' Join Domain tmpReturnCode = pcEnumerator.JoinDomainOrWorkGroup _ (DOMAIN_NAME, DOMAIN_PASSWORD, DOMAIN_NAME & "\" & DOMAIN_ADMINISTRATOR, _ vbNullString, JOIN_DOMAIN + ACCT_CREATE) If tmpReturnCode <> 0 Then WScript.Echo "Join failed. Error = " & Err.Number WshShell.LogEvent evError, "ドメインの参加に失敗しました。" & Err.Description Else WScript.Echo "Joined Domain" WshShell.LogEvent evInfomation, "ドメインに参加しました。再起動が必要です。" ' WshShell.run "C:\WINDOWS\system32\shutdown.exe /r /t 10" End if Next </script> </job>