> For the complete documentation index, see [llms.txt](https://cajac.gitbook.io/ctf-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cajac.gitbook.io/ctf-notes/enum/windows-discovery/windows-user-information.md).

# Windows User Information

## Command history

### cmd.exe command history

Get current command history in cmd.exe

```batch
doskey.exe /history
```

### Get-PSReadline module history

Get the name of the history log file

```powershell
(Get-PSReadlineOption).HistorySavePath
```

The default location is \
`C:\Users\<user>\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ ConsoleHost_history.txt`

### PowerShell command history

Get current command history in PowerShell

```powershell
Get-History
```

## Current user information

### Current user info in cmd.exe

Display current username in cmd.exe

```batch
echo %USERNAME%
```

### Current user info in PowerShell

Display current username in PowerShell

```powershell
$env:username
```

### Current user info with whoami.exe

List username of current user

```
whoami
```

List username and SID of current user

```
whoami /user
```

Displays the user groups to which the current user belongs

```
whoami /groups
```

Displays the security privileges of the current user

```
whoami /priv
```

Display all user information

```
whoami /all
```

## List user information

### List user info with Get-LocalUser

List information for specified local user

```powershell
Get-LocalUser -Name <user> | select *
```

List username, full name and description of all local users

```powershell
Get-LocalUser | Select-Object Name, Fullname, Description
```

List username, enabled or not, last logon time and SID of all local users

```powershell
Get-LocalUser | Format-Table Name, Enabled, LastLogon, SID
```

### List user info with net.exe

List all local users

```
net user
```

Displays username, password expiration information, logon script, user profile, home directory, and group membership for the user

```
net user <username>
```

## Group information&#x20;

### Group information with net.exe

List all local groups

```
net localgroup
```

## Resources

Get-LocalUser - Microsoft Learn: <https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.localaccounts/get-localuser?view=powershell-5.1>

net user - Microsoft Learn: <https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/cc771865(v=ws.11)>

whoami - Microsoft Learn: <https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/whoami>
