大网数据广告活动
Windows排障命令

whoami

· 52CE 我爱测

Reference article for whoami, which displays user, group and privileges information for the user who is currently logged on to the local system.

The whoami command shows information about the user, groups, and privileges for the account currently logged on to the local system. When run without any parameters, whoami returns the current domain and user name.

Syntax

whoami [/upn | /fqdn | /logonid]
whoami {[/user] [/groups] [/claims] [/priv]} [/fo <format>] [/nh]
whoami /all [/fo <format>] [/nh]

Parameters

Parameter Description
:::no-loc text="/upn"::: Displays the user name in user principal name (UPN) format.
:::no-loc text="/fqdn"::: Displays the user name in fully qualified domain name (FQDN) format.
:::no-loc text="/logonid"::: Displays the logon ID of the current user.
:::no-loc text="/user"::: Displays the current domain and user name and the security identifier (SID).
:::no-loc text="/groups"::: Displays the user groups to which the current user belongs.
:::no-loc text="/claims"::: Displays the claims for current user, such as claim name, flags, type and values.
:::no-loc text="/priv"::: Displays the security privileges of the current user.
:::no-loc text="/fo"::: <format> Specifies the output format. Valid values include:<li> table - Displays output in a table. This is the default value. <li> :::no-loc text="list"::: - Displays output in a list. <li> csv - Displays output in comma-separated value (CSV) format. </li>
:::no-loc text="/all"::: Displays all information in the current access token, including the current user name, security identifiers (SID), privileges, and groups that the current user belongs to.
:::no-loc text="/nh"::: Specifies that the column header shouldn't be displayed in the output. This is valid only for table and CSV formats.
:::no-loc text="/?"::: Displays help at the command prompt.

Examples

To display the domain and user name of the person who is currently logged on to this computer, type:

whoami

Output similar to the following appears:

DOMAIN1\administrator

To display all of the information in the current access token, type:

whoami /all

Related links

Source: Microsoft Learn / Windows Server documentation by Microsoft and contributors (upstream author metadata: robinharwood). Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Server documentation
适用范围
Windows Server · Source date 05/23/2025
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。