本文提供了一个解决方案,用于将命令与超过 20 个字符的用户或组名称一 NET.EXE /ADD 起使用时发生的错误。
原始 KB 数: 324639
现象
将 NET.EXE 命令与 /ADD 开关和长用户或组名称一起使用时,这只会重播 NET 语法。 不会收到错误消息。
示例:
C:\>NET.EXE localgroup MyRemoteUsers "REMOTE INTERACTIVE LOGON" /ADD
The syntax of this command is:
NET LOCALGROUP [groupname [/COMMENT:"text"]] [/DOMAIN]
groupname {/ADD [/COMMENT:"text"] | /DELETE} [/DOMAIN]
groupname name [...] {/ADD | /DELETE} [/DOMAIN]
相同的操作 适用于 GUI 计算机管理、本地用户和组Microsoft管理控制台(MMC)。
原因
由于与 LAN Manager 2.0 向后兼容的原因,NET.EXE命令不支持名称超过 20 个字符。
解决方法
如果无法使用图形用户界面(GUI)方法,并且需要脚本方法,请使用 Windows 2000 资源工具包实用工具Cusrmgr.exe。 或者,使用支持名称超过 20 个字符的应用程序编程接口(API)使用 VBScript。
Status
Microsoft 已经确认这是一个列于“适用范围”部分的 Microsoft 产品问题。
详细信息
在本文的“症状”部分中的示例中,使用以下Cusrmgr.exe语法:
C:\>CUSRMGR.EXE -u "REMOTE INTERACTIVE LOGON" -alg "MyRemoteUsers"
在内置组超过 20 个字符名称限制的本地化版本中,也可能出现此问题。 例如,使用德语名称“经过身份验证的用户”(19 个字符):“Authentifizierte Benutzer”(25 个字符)。
以下示例 VBScript 可以改编并用作其他解决方法。 它将英语和德语版本的“经过身份验证的用户”添加到“Power Users”:
##### VBScript ADDGRP.VBS #####
On Error Resume Next
Dim oContainer
Dim oGroup
Dim oIADs
Dim oComputerInformation
Dim bolGroupSet
bolGroupSet = False
Set oComputerInformation = CreateObject("WScript.Network")
Set oContainer = GetObject("WinNT://" +
oComputerInformation.ComputerName)'get the IADsContainer object for the local computer
oContainer.Filter = Array("Group")'We only need to enumerate groups,
therefore the filter
For Each oIADs In oContainer 'for each IADs object we find there
If oIADs.Name = "Hauptbenutzer" Or oIADs.Name = "Power Users" Then
'check if it has the name "Power Users" or "Hauptbenutzer"
Set oGroup = oIADs 'If so put it into the IADsGroup object
oGroup.Add ("WinNT://S-1-5-11")'add the group "Authenticated Users"
oGroup.SetInfo 'and save the info
If Err <> 0 Then 'if error number is not 0 (Error occurred)
MsgBox Err.Number, vbCritical, "AddGroup" 'print out the error message
Else 'if everything seems to be ok
bolGroupSet = True 'set the boolean value to True so we know the group was added
End If
End If
Next
If bolGroupSet = True Then 'if bolGroupSet is False there was nothing done
MsgBox "Group added successfully", vbInformation, "AddGroup"
Else
MsgBox "No action has taken place!", vbExclamation, "AddGroup"
End If
##### script end #####
解决方法
若要在 Windows Server 2008 及更高版本中解决此问题,请使用 Add-ADGroupMember PowerShell 命令,如以下 TechNet 文章中所述: Add-ADGroupMember
如果使用 PowerShell 5.1,请使用 Add-LocalGroupMember -Group PowerShell 命令,如以下文章中所述:Add-LocalGroupMember