Имя пользователя:
Пароль:
 

Показать сообщение отдельно

Новый участник


Сообщения: 11
Благодарности: 0

Профиль | Отправить PM | Цитировать


Кстати, нашёл ещё один скрипт для переименования, существенно ускоряет процесс. Вдруг кому пригодится

Код: Выделить весь код
Dim RegKeyCompName, RegKeyTCPIP, WSHShell, ComputerName, HostName, DomainName, FQDN, ADRootDSE, ADSysInfo, ADComputerName, ADRenameOK, ADRNewName, vStartRenameCA, NewNAmeU, NewNameL, vStartRenameAD

On Error Resume Next

'###### READ IN EXISTING COMPUTERNAME AND FQDN ######

RegKeyCompName = "HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\"
RegKeyTCPIP = "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\"

Set WSHShell = CreateObject("WScript.Shell")

ComputerName = WSHShell.RegRead (RegKeyCompName & "ComputerName\ComputerName")
Hostname = WSHShell.RegRead (RegKeyTCPIP & "Hostname")
DomainName = WSHShell.RegRead (RegKeyTCPIP & "Domain")
FQDN = HostName & "." & DomainName

Set ADRootDSE = GetObject("LDAP://RootDSE")
If Err.Number <> 0 then
    ADComputerName = "Unable to determine this information"
    ADOU = "Unable to determine this information"
    ADRenameOK = "0"
else
    Set ADSysInfo = CreateObject("ADSystemInfo")
    ADComputerName = ADSysInfo.ComputerName                'Get DN of local computer
    ADRenameOK = "1"
    ADOU = Mid(ADComputerName, InStr(ADComputerName, "=") + 1)    'Strip off just after the first = sign
    ADOU = Mid(ADOU, InStr(ADOU, "=") - 2)                'Strip off at 2 before the second = sign
    ComputerPath = "LDAP://" & ADComputerName
    OUPath = "LDAP://" & ADOU
End if

'###### ASK USER FOR NEW DETAILS ###########

MsgBox "This script renames this computer and its active directory account" & vbCr & vbCr & "Name: " & ComputerName & vbCr & "FQDN: " & FQDN & vbCr & vbCr & "AD DN: " & ADComputerName & vbCr & "AD OU: " & ADOU, 0, "Information"

NewName = InputBox("Enter the new computer name below and click OK to continue","Rename: Step 1")
NewNameU = UCase(NewName)
NewNameL = LCase(NewName)
NewNameUCN = "CN=" & NewNameU

if NewName = "" then
    wscript.echo "The computer name has not been changed"
else
    vStartRenameCA = MsgBox ("Continue and rename computer to: " & NewName,vbYesNo or vbExclamation,"Rename: Step 2")
    if vStartRenameCA = 6 then
        With WSHShell
            .RegDelete RegKeyTCPIP & "Hostname"
            .RegDelete RegKeyTCPIP & "NV Hostname"
            .RegWrite RegKeyCompName & "ComputerName\ComputerName", NewNameU
            .RegWrite RegKeyCompName & "ActiveComputerName\ComputerName", NewNameU
            .RegWrite RegKeyTCPIP & "Hostname", NewNameL
            .RegWrite RegKeyTCPIP & "NV Hostname", NewNameL
        End With
        wscript.echo "The computer name and FQDN have been changed"
    elseif vStartRenameCA = 7 then
        wscript.echo "The computer name and FQDN have NOT been changed"
    end if

    if ADRenameOK = 1 then
        vStartRenameAD = MsgBox ("Continue and rename AD Account to: " & NewName,vbYesNo or vbExclamation,"Rename: Step 3")
        if vStartRenameAD = 6 then
            Set objItem = GetObject(ComputerPath)
            objItem.Put "dNSHostName", NewNameL & DomainName
            objItem.SetInfo
            objItem.Put "displayName", "DESKTOP_" & NewNameU & "$"
            objItem.SetInfo
            objItem.Put "sAMAccountName", NewNameU & "$"
            objItem.SetInfo

            Set objNewOU = GetObject(OUPath)
            Set objMoveComputer = objNewOU.MoveHere _
                (ComputerPath, NewNameUCN)
            wscript.echo "The active directory computer account has been changed"
        elseif vStartRenameAD = 7 then
            wscript.echo "The computer account in AD has NOT been changed"
        End If
    else
        wscript.echo "Insufficient information to rename AD account"

    End If

End if
И ещё пара интересных ссылок по сходной тематике:
http://calnetad.berkeley.edu/documentation/scripts/
http://thelazyadmin.com/

Отправлено: 12:15, 30-01-2006 | #10