Get-LocalUser
获取本地用户帐户。
语法
Default (默认值)
Get-LocalUser
[[-Name] <String[]>]
[<CommonParameters>]
SecurityIdentifier
Get-LocalUser
[[-SID] <SecurityIdentifier[]>]
[<CommonParameters>]
说明
Get-LocalUser
cmdlet 获取本地用户帐户。 此 cmdlet 获取默认的内置用户帐户、你创建的本地用户帐户以及连接到 Microsoft 帐户的本地帐户。
注释
Microsoft.PowerShell.LocalAccounts 模块在 64 位系统上的 32 位 PowerShell 中不可用。
示例
示例 1:使用帐户名称获取帐户
此示例获取名为 AdminContoso02 的用户帐户。
Get-LocalUser -Name "AdminContoso02"
Name Enabled Description
---- ------- -----------
AdminContoso02 True Description of this account.
示例 2:获取连接到Microsoft帐户的帐户
此示例获取连接到Microsoft帐户的用户帐户。 此示例使用占位符值作为 Outlook.com 帐户的用户名。
Get-LocalUser -Name "MicrosoftAccount\username@Outlook.com"
Name Enabled Description
---- ------- -----------
MicrosoftAccount\username@outlook.com True Description of this account.
示例 3:获取具有指定 SID 的帐户
此示例获取具有指定 SID 的本地用户帐户。
Get-LocalUser -SID S-1-5-21-9526073513-1762370368-3942940353-500
Name Enabled Description
---- ------- -----------
Administrator True Built-in account for administering the computer/domain
参数
-Name
指定此 cmdlet 获取的用户帐户的名称数组。 可以使用通配符。
参数属性
类型: | String[] |
默认值: | None |
支持通配符: | True |
不显示: | False |
参数集
Default
Position: | 0 |
必需: | False |
来自管道的值: | True |
来自管道的值(按属性名称): | True |
来自剩余参数的值: | False |
-SID
指定此 cmdlet 获取的用户帐户的安全 ID(SID)数组。
参数属性
类型: | |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
SecurityIdentifier
Position: | 0 |
必需: | False |
来自管道的值: | True |
来自管道的值(按属性名称): | True |
来自剩余参数的值: | False |
CommonParameters
此 cmdlet 支持通用参数:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 有关详细信息,请参阅 about_CommonParameters。
输入
String
可以通过管道将字符串传递给此 cmdlet。
SecurityIdentifier
可以通过管道将 SID 传递给此 cmdlet。
输出
System.Management.Automation.SecurityAccountsManager.LocalUser
此 cmdlet 返回本地用户帐户。
备注
Windows PowerShell 为 Get-LocalUser
提供以下别名:
glu
localUser 、LocalGroup上的 PrincipalSource 属性,LocalPrincipal 对象描述对象的源。 可能的源如下所示:
- 本地
- Active Directory
- Microsoft Entra 组
- Microsoft 帐户
PrincipalSource 仅受 Windows 10、Windows Server 2016 和更高版本的 Windows 操作系统支持。 对于早期版本,该属性为空。