To list the user names having accounts on the local system, you can run the following command from Command Prompt in Windows 11 or Windows 10.
net user
This lists local user accounts, not just users who are currently signed in.
List domain user accounts
If the computer belongs to an Active Directory domain, we can use /domain to list accounts from that domain:
net user /domain
The computer needs to be able to contact its domain controller.
Find the current user name
If you only want the account running the current Command Prompt, use:
whoami
This shows the domain or computer name followed by the user name.