“wmic useraccounts” is a Windows Management Instrumentation Command-line utility that retrieves information about user accounts on a system, providing details such as username, full name, and SID. This example gives the username with corresponding SID.
Command:wmic useraccount get name,sid