Get-LocalUser
获取本地用户帐户。
语法
Get-LocalUser
[[-Name] <String[]>]
[<CommonParameters>]
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 获取的用户帐户的名称数组。 可以使用通配符。
Type: | String[] |
Position: | 0 |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | True |
-SID
指定此 cmdlet 获取的用户帐户的安全 ID (SID) 数组。
Type: | SecurityIdentifier[] |
Position: | 0 |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
输入
可以通过管道将字符串传递给此 cmdlet。
可以通过管道将 SID 传递给此 cmdlet。
输出
System.Management.Automation.SecurityAccountsManager.LocalUser[]
此 cmdlet 返回本地用户帐户。
备注
Windows PowerShell 包含以下 Get-LocalUser
别名:
glu
LocalUser、LocalGroup 和 LocalPrincipal 对象上的 PrincipalSource 属性描述了对象的源。 可能的源如下所示:
- Local
- Active Directory
- Microsoft Entra 组
- Microsoft 帐户
PrincipalSource仅受 Windows 10、Windows Server 2016 及更高版本的 Windows 操作系统支持。 对于早期版本,该属性为空。
相关链接
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈