在服务器之间复制NT用户帐户

我在Windows 2003 Server上创build了大约50个用户帐户,我想将这些帐户复制到新的服务器上,这可能吗? 我没有使用Active Directory。

帕特里克

编辑1:谢谢你的答案,但我应该在我原来的问题更具体。 我想复制用户帐户并维护现有的密码。 另外,我想复制互联网和防火墙上的两台服务器之间的帐户。 是否可以简单地备份和恢复用户帐户?

命令“net user”将显示所有用户帐户的列表。 如果您运行此pipe道输出到一个文件,然后可以编辑该文件将其转换为一个脚本来创build新服务器的帐户。 使用“networking帮助用户”来查看如何从batch file创build帐户。 在创build帐户之后,您可能不得不手动调整帐户,但与使用GUI相比,仍然是一个节省时间的方法。

注意你将无法提取旧的密码。 如果你不知道你的用户密码是什么,你将不得不把他们全部设置为默认值,然后逐个更改它们。

JR

John的post刚刚提醒我:MS上有一个名为AddUsers的小程序可以帮助解决这类问题。 有关详细信息,请参阅http://support.microsoft.com/kb/199​​878

这里有一个VBscript程序将本地组和用户帐户从源计算机复制到目标计算机:

Option Explicit Dim dictGroupsNotToCreate, dictPropertiesToCopy, dictUsersToIgnore, objNetwork Dim colSourceGroups, colDestinationGroups, objSourceGroup, objDestinationGroup, objUser Dim colSourceAccounts, colDestinationAccounts, objSourceUser, objDestinationUser, property ' Debugging Const DEBUGGING = True ' Source and destination computers Const SOURCE_COMPUTER = "PC00623" Const DESTINATION_COMPUTER = "PC00619" ' Password to set on newly create user accounts Const DEFAULT_PASSWORD = "rh1n0s!!!" ' Constants for comparison of accounts to ignore list Const MATCH_EXACT = 1 Const MATCH_LEFT = 2 Set dictGroupsNotToCreate = CreateObject("Scripting.Dictionary") dictGroupsNotToCreate.Add "Administrators", MATCH_EXACT dictGroupsNotToCreate.Add "Backup Operators", MATCH_EXACT dictGroupsNotToCreate.Add "Guests", MATCH_EXACT dictGroupsNotToCreate.Add "Network Configuration Operators", MATCH_EXACT dictGroupsNotToCreate.Add "Power Users", MATCH_EXACT dictGroupsNotToCreate.Add "Remote Desktop Users", MATCH_EXACT dictGroupsNotToCreate.Add "Replicator", MATCH_EXACT dictGroupsNotToCreate.Add "Users", MATCH_EXACT dictGroupsNotToCreate.Add "Debugger Users", MATCH_EXACT dictGroupsNotToCreate.Add "HelpServicesGroup", MATCH_EXACT ' Properties of user accounts to copy Set dictPropertiesToCopy = CreateObject("Scripting.Dictionary") dictPropertiesToCopy.Add "Description", True dictPropertiesToCopy.Add "FullName", True dictPropertiesToCopy.Add "HomeDirDrive", True dictPropertiesToCopy.Add "HomeDirectory", True dictPropertiesToCopy.Add "LoginHours", True dictPropertiesToCopy.Add "LoginScript", True dictPropertiesToCopy.Add "Profile", True ' Accounts to ignore during copying Set dictUsersToIgnore = CreateObject("Scripting.Dictionary") dictUsersToIgnore.Add "SUPPORT_", MATCH_LEFT dictUsersToIgnore.Add "IUSR_", MATCH_LEFT dictUsersToIgnore.Add "IWAM_", MATCH_LEFT dictUsersToIgnore.Add "Administrator", MATCH_EXACT dictUsersToIgnore.Add "Guest", MATCH_EXACT dictUsersToIgnore.Add "HelpAssistant", MATCH_EXACT dictUsersToIgnore.Add "ASPNET", MATCH_EXACT ' Should this account be ignored Function IgnoreObject(Name, dictNames) Dim strToIgnore IgnoreObject = False For Each strToIgnore in dictNames ' Match Exact If (dictNames.Item(strToIgnore) = MATCH_EXACT) and (UCase(Name) = UCase(strToIgnore)) Then IgnoreObject = True Exit Function End If ' Match left If (dictNames.Item(strToIgnore) = MATCH_LEFT) and (Left(UCase(Name), Len(strToIgnore)) = UCase(strToIgnore)) Then IgnoreObject = True Exit Function End If Next' strToIgnore End Function Set objNetwork = CreateObject("Wscript.Network") ' Get groups on source computer and loop through them, copying as necessary Set colSourceGroups = GetObject("WinNT://" & SOURCE_COMPUTER) Set colDestinationGroups = GetObject("WinNT://" & DESTINATION_COMPUTER) colSourceGroups.Filter = Array("group") For Each objSourceGroup in colSourceGroups If IgnoreObject(objSourceGroup.Name, dictGroupsNotToCreate) = False then If (DEBUGGING) Then WScript.Echo "Creating Group: " & objSourceGroup.Name Set objDestinationGroup = colDestinationGroups.Create("group", objSourceGroup.Name) objDestinationGroup.Put "Description", objSourceGroup.Get("Description") objDestinationGroup.SetInfo Else If (DEBUGGING) Then WScript.Echo "Ignoring Group: " & objSourceGroup.Name End If Next ' objSourceGroup ' Get accounts on source computer and loop through them, copying as necessary Set colSourceAccounts = GetObject("WinNT://" & SOURCE_COMPUTER) set colDestinationAccounts = GetObject("WinNT://" & DESTINATION_COMPUTER) colSourceAccounts.Filter = Array("user") For Each objSourceUser In colSourceAccounts If IgnoreObject(objSourceUser.Name, dictUsersToIgnore) = False Then If (DEBUGGING) Then WScript.Echo "Copying account: " & objSourceUser.Name On Error Resume Next Set objDestinationUser = colDestinationAccounts.Create("user", objSourceUser.Name) objDestinationUser.SetPassword DEFAULT_PASSWORD objDestinationUser.SetInfo ' Copy properties from source user to destination user For Each property in dictPropertiesToCopy If (DEBUGGING) then WScript.Echo " Copying property " & property & " (" & objSourceUser.Get(property) & ")" objDestinationUser.Put property, objSourceUser.Get(property) objDestinationUser.SetInfo Next ' property ' Put user into destination groups For Each objSourceGroup In colSourceGroups For Each objUser In objSourceGroup.Members If UCase(objUser.Name) = Ucase(objSourceUser.Name) Then If (DEBUGGING) Then WScript.Echo "Adding user " & objSourceUser.Name & " to group " & objSourceGroup.Name Set objDestinationGroup = GetObject("WinNT://" & DESTINATION_COMPUTER & "/" & objSourceGroup.Name & ",group") objDestinationGroup.Add(objDestinationUser.aDSPath) Else If (DEBUGGING) Then WScript.Echo "User " & objSourceUser.Name & " is not a member of group " & objSourceGroup.Name End If Next ' objUser Next 'objSourceGroup Else If (DEBUGGING) Then WScript.Echo "Ignoring account: " & objSourceUser.Name End If Next ' objSourceUser 

快速浏览:

  • 设置SOURCE_COMPUTER和DESTINATION_COMPUTER名称
  • 设置DEFAULT_PASSWORD(将分配给新创build的用户帐户)
  • 将不应在目标计算机上创build的任何本地组名称添加到dictGroupsNotToCreate列表中。 MATCH_EXACT表示组的名称完全匹配。 MATCH_LEFT意味着只有组名的最左边部分将被匹配(即,想象名称匹配后面有一个“*”)。
  • 将不应在目标计算机上创build的任何本地用户名添加到dictUsersToIgnore LIST。 MATCH_EXACT和MATCH_LEFT的含义与dictGroupsNotToCreate列表相同(即“IUSR_”,MATCH_LEFT意味着不会在目标计算机上创build任何以“IUSR_”开头的用户帐户)。

您必须使用有权在目标计算机上创build帐户的凭据来执行此脚本。

默认情况下,为用户帐户复制的属性列在dictPropertiesToCopy列表中。 我select了最常见的属性。

该脚本已经过相当好的testing,但我没有在生产环境中使用它。 它不改变源服务器,所以你可以运行它,而不用担心损坏源服务器。

(不,群体algorithm不是很有效率,如果你感到困扰,那么你已经足够了解了,重新实施它就更好了… …)

在过去的几天中,我使用了一个来自Microsoft的命令行实用程序,它允许您将帐户(使用密码哈希)完成转储到可以在另一台计算机上导入的文本文件。 不幸的是,我不记得它的名字。

您可以尝试使用2003 Resource Kit中的moveuser 。 通过阅读,它似乎被devise为移动域之间的用户,但我可以谷歌引用到它用于本地 – >域名移动。 让我怀疑是否也可能有本地到本地。