Windows CMDInteractive Lab
windows commands

whoami /groups /fo csv Output Headers Explained

Learn the exact headers returned by whoami /groups /fo csv, what each column means, and how to parse output safely in scripts and audits.

Rojan Acharya··Updated Apr 20, 2026
Share

The whoami /groups /fo csv command returns your current access token groups as structured CSV data, including columns for group name, type, SID, and attributes. If you are building scripts, SOC checks, or compliance exports, understanding these headers prevents parsing mistakes and wrong access conclusions.

This guide breaks down every default CSV header, when /nh removes headers, and how to make output stable for automation. You will also see practical examples, troubleshooting steps, and a quick reference for day-to-day operations.

What Is whoami /groups /fo csv Output?

whoami /groups /fo csv prints token group data in comma-separated format so the output can be imported by tools like Excel, PowerShell, SIEM pipelines, and internal audit scripts. CSV format is much safer for machines than table output because it is explicit and consistent.

Syntax

whoami /groups /fo csv
whoami /groups /fo csv /nh
SwitchMeaning
/groupsLists security groups in current token
/fo csvUses CSV format
/nhRemoves header row

Output Headers and Meaning

By default, Windows returns these headers in CSV mode:

HeaderWhat it meansWhy it matters
Group NameDisplay name of the groupHuman-readable identity
TypeGroup classificationDistinguishes alias/well-known/etc
SIDSecurity identifierReliable matching key in scripts
AttributesToken flagsShows enabled, mandatory, deny-only

Group Name

Use this for analyst readability, ticket notes, and quick checks.

Type

Use this to understand whether a row is a local alias, a well-known group, or another group class.

SID

Use SID for deterministic automation because names can vary by language or domain naming.

Attributes

Use attributes to understand token behavior, especially for "Enabled", "Mandatory", or deny-related flags.

Examples

1. Default CSV with headers

whoami /groups /fo csv

2. CSV without headers for append pipelines

whoami /groups /fo csv /nh

3. Save CSV for audit evidence

whoami /groups /fo csv > C:\Temp\token-groups.csv

4. Append periodic snapshots

whoami /groups /fo csv /nh >> C:\Temp\token-groups-history.csv

5. Pair user identity with group export

whoami && whoami /groups /fo csv > C:\Temp\whoami-groups.csv

6. Import in PowerShell

whoami /groups /fo csv | ConvertFrom-Csv | Select-Object "Group Name", Type, SID, Attributes

Common Use Cases

  • Incident triage when analysts must verify whether high-risk groups are in the token.
  • Audit exports where evidence must be attached in machine-readable format.
  • Privilege troubleshooting when access denied errors conflict with expected role membership.
  • Endpoint baseline checks that compare current SIDs against approved policy sets.
  • Helpdesk escalations that require reproducible context and token proof.

Tips and Best Practices

  • Prefer SID-based matching in scripts, not only group display names.
  • Use /nh only when your parser explicitly expects headerless rows.
  • Always log hostname, whoami, and timestamp beside exported CSV.
  • Keep one command format across your team to reduce parser drift.
  • Store raw CSV before transformation so investigations remain reproducible.

Troubleshooting Common Issues

CSV parser fails unexpectedly

Use explicit quoting-safe parsers like ConvertFrom-Csv instead of manual split logic.

Missing expected groups

User may need new logon token; sign out and sign back in after group changes.

Different headers across environments

Locale can affect display text; normalize by SID where possible.

Data looks right but access still denied

Check token attributes and UAC context, not only membership names.

Related Commands

whoami /priv

Complements group membership by showing privilege state.

whoami /all

Returns consolidated identity, groups, and privileges.

gpresult

Helps correlate policy application with token outcomes.

icacls

Validates ACL side of the permission decision.

Frequently Asked Questions

What are the default headers for whoami /groups /fo csv?

They are typically Group Name, Type, SID, and Attributes.

Does /nh remove all column names?

Yes. /nh suppresses the header row, which is useful for append workflows.

Should I parse Group Name or SID?

Parse SID for stable automation; use Group Name for reporting readability.

Is table format better than CSV?

For automation and audits, CSV is better; table format is better for quick visual checks.

Why do I see unexpected attributes?

Token attributes depend on logon type, UAC context, and policy.

Can I use this in PowerShell?

Yes, pipe CSV output to ConvertFrom-Csv for object-based handling.

Why did a newly added group not appear?

Token refresh usually requires sign-out/sign-in.

Is this safe for production diagnostics?

Yes, this command is read-only and ideal for evidence collection.

Quick Reference Card

CommandPurposeExample
whoami /groups /fo csvCSV with headersbaseline export
whoami /groups /fo csv /nhCSV no headersappend pipelines
whoami /groups /fo csv > file.csvsave reportaudit artifacts
whoami /groups /fo csv /nh >> file.csvappend snapshotsdrift tracking

Call to Action

Summary

whoami /groups /fo csv gives stable, script-friendly token group output. If you understand headers and handle /nh intentionally, you can build safer audits, cleaner pipelines, and faster incident workflows. Use SID-centric parsing, keep evidence artifacts, and pair output with context checks for production-grade operations.