How to get logged in username when running Powershell as Administrator?

Viewed 28

I tried to run this command in powershell: (Get-CimInstance -ClassName Win32_ComputerSystem).Username

But it prints me an empty string.

Is there a command to get the output? this command worked for me on other machine but not on different machine.

Worked on machine with version of powershell: Major: 5 Minor: 1 Build: 19041 Revision: 1682

Did not work on powershell version: Major: 5 Minor: 1 Build: 17763 Revision: 2931

0 Answers
Related