背景:
尝试将
Windows-11 Home
版本的语言设置从 ES 更改为 US。
我设法完成了大部分更改,但仍有其他几个项目*以西班牙语返回。
返回西班牙团体的一个例子:
Get-LocalGroup
Name Description
---- -----------
Administradores Los administradores tienen acceso completo y sin
Device Owners Los miembros de este grupo pueden cambiar la …
Hyper-V Administrators Members of this group have complete and unrestricted …
IIS_IUSRS Grupo integrado usado por Internet Information Services.
Invitados De forma predeterminada, los invitados tienen el mismo…
...
进一步了解这些群组如何/为何使用西班牙语,我运行了
whoami /groups
和 net localgroup
。我得到以下输出,显示某些组在 Alias
列下列为
Type
。
# whoami /groups
Group Name Type SID Attributes
============================================================= ================ ============ ===============================================================
Everyone Well-known group S-1-1-0 Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\Local account and member of Administrators group Well-known group S-1-5-114 Mandatory group, Enabled by default, Enabled group
BUILTIN\Administradores Alias S-1-5-32-544 Mandatory group, Enabled by default, Enabled group, Group owner
BUILTIN\Usuarios Alias S-1-5-32-545 Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\INTERACTIVE Well-known group S-1-5-4 Mandatory group, Enabled by default, Enabled group
CONSOLE LOGON Well-known group S-1-2-1 Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\Authenticated Users Well-known group S-1-5-11 Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\This Organization Well-known group S-1-5-15 Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\Local account Well-known group S-1-5-113 Mandatory group, Enabled by default, Enabled group
LOCAL Well-known group S-1-2-0 Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\NTLM Authentication Well-known group S-1-5-64-10 Mandatory group, Enabled by default, Enabled group
Mandatory Label\High Mandatory Level Label S-1-16-12288
# net localgroup
Aliases for \\LAPTOP-xxxx
------------------------------------------
*Administradores
*Device Owners
*Hyper-V Administrators
*IIS_IUSRS
*Invitados
*Lectores del registro de eventos
*System Managed Accounts Group
*Usuarios
*Usuarios COM distribuidos
*Usuarios de administración remota
*Usuarios del monitor de sistema
*Usuarios del registro de rendimiento
The command completed successfully.
问:如何删除这些群组别名并查看原来的群组名称?
Bonus Question
:相关问题:
net localgroup
输出中的术语
alias有点误导,因为它只是指组的name(您可以将其视为组的不变标识符的别名,即SID) )。
以下信息似乎是根据操作系统附带的 Windows 显示(用户界面)语言“静态”分配的: 内置
本地用户和组帐户的Administrators
(英语)/Administradores
(西班牙语)。他们的描述。
,如链接问题的此答案中所述)不会更改此信息,因此您唯一的选择是自己执行此操作 -请参阅下一节。
除了可以通过 lusrmgr.msc
重命名此类帐户并更新其描述之外,您还可以以编程方式:
注意事项:重命名用户和组帐户可能会破坏现有脚本
(除非它们碰巧使用 SID 而不是名称)。对于Windows来说,首先本地化这些名称是一个不幸的设计决定,正是因为它阻碍了代码在使用不同显示语言的机器之间的可移植性,或者就像您的情况一样,切换到不同的显示语言。
# Establish a mapping by SID for all built-in *groups*
# to their English names and descriptions.
# See below for how to create this hashtable programmatically.
$sidMap_Groups =
[ordered] @{
'S-1-5-32-544' = [ordered] @{
Name = 'Administrators'
Description = 'Administrators have complete and unrestricted access to the computer/domain'
}
# ...
}
# Ditto for built-in *users*, but with keys based on the
# *last SID component* only.
$sidMap_Users =
[ordered] @{
'500' = [ordered]@{
Name = 'Administrator'
Description = 'Built-in account for administering the computer/domain'
}
# ...
}
# Rename and update built-in *groups*
Get-LocalGroup |
ForEach-Object {
if ($entry = $sidMap_Groups[$_.SID.Value]) {
# !! See below for why Set-LocalGroup is *not* an option.
net localgroup $_.Name /comment:$($entry.Description)
$_ | Rename-LocalGroup -NewName $entry.Name
}
}
# Rename and update built-in *users*
Get-LocalUser |
ForEach-Object {
if ($entry = $sidMap_Users[($_.SID.Value -split '-')[-1]]) {
# !! See below for why Set-LocalUser is *not* an option.
net user $_.Name /comment:$($entry.Description)
$_ | Rename-LocalUser -NewName $entry.Name
}
}
注:
令人费解的是,
Set-LocalUser
,从其封闭的
Microsoft.PowerShell.LocalAccounts
模块的1.0.0.0版本开始,对传递给其-Description
参数的值有严格的48个字符限制。 相比之下,
net.exe
,通过其 localgroup
user
子命令,
not的
/comment
参数是否有此限制,这就是上面使用它的原因。
如果您可以使用以英语作为显示语言的机器,则可以创建 $sidMap_Groups
和 $sidMap_Users
$sidMap_Groups = [ordered] @{}
Get-LocalGroup |
Where-Object {
# Infer whether an account is built-in from the number of SID components.
($_.SID.Value -split '-').Count -eq 5
} |
ForEach-Object {
$sidMap_Groups[$_.SID.Value] = [ordered] @{ Name = $_.Name; Description = $_.Description }
}
$sidMap_Users = [ordered] @{}
Get-LocalUser |
Where-Object {
# Infer whether an account is built-in from the last SID component.
[int] ($_.SID.Value -split '-')[-1] -lt 1000
} |
ForEach-Object {
$sidMap_Users[($_.SID.Value -split '-')[-1]] = [ordered] @{ Name = $_.Name; Description = $_.Description }
}