If you are using PowerShell prompt on Mac Terminal and want to know who is currently logged in, you can make use of the below commands,
Option 1: who command
PS /> who
code2care console Sep 14 10:58
code2care ttys000 Sep 14 10:58
code2care ttys001 Sep 14 10:58
Option 2: whoami command
PS /> whoami
code2care
Option 3: $env:USER command
PS /> $env:USER
code2care
Note: As PowerShell is not native to macOS, the command that works on PowerShell for Windows may not work and you will get an error.
PS /> (Get-WmiObject -Class Win32_ComputerSystem).UserName
Get-WmiObject: The term 'Get-WmiObject' is not recognized as a name of a cmdlet,
function, script file, or executable program.
Check the spelling of the name, or if a path was included,
verify that the path is correct and try again.

-
Facing issues? Have Questions? Post them here! I am happy to answer!
More Posts related to Powershell,
- PowerShell: How to Check if a Module is Already Installed
- PowerShell: How to Write Output to a File
- PowerShell: Steps to Connect to connect to Exchange Online
- PowerShell Fix: Get-Help cannot find the Help files for this cmdlet on this computer
- PowerShell Traditional For Loop Example
- How to Run PowerShell Script as Administrator (Elevate)
- Update Powershell Using Command Line
- How to delete a file using PowerShell [Windows/macOS]
- PowerShell: Grep Command Alternative - Select-String
- PowerShell Concatenate String Examples
- How to add Sleep to PowerShell Script
- Connect Azure AD (Active Directory) for PowerShell
- How to Open PowerShell on Mac?
- List of PowerShell Function Commands for Mac
- How to Connect to Azure AD Account using PowerShell on Mac
- Download Google Chrome setup exe file using PowerShell
- Set Environment Variable in PowerShell for Mac
- How to switch to Powershell on Mac Terminal
- How to add sleep in Powershell Script
- PowerShell on Mac: The term get-service is not recognized as a name of a cmdlet, function, script file, or executable program
- How to Identify installed PowerShell version
- How to check PowerShell version
- How to install PowerShell on Mac using Brew
- PowerShell Switch Statement with Examples
- PowerShell ISE Alternative for Mac
More Posts:
- How to Scan iPhone for Virus? Is Antivirus it really required? - HowTos
- [Java Threads] Should we extend Thread Class or implement Runnable interface - Java
- Microsoft Edge browser error on MAC - This page is having a problem Try coming back to it later - Microsoft
- Install Notepad++ silently using Windows Powershell - NotepadPlusPlus
- TextEdit Find and Replace Example - MacOS
- How to Copy a remote file to local using SFTP command? - FTP
- Add Line Break (New Line) in Jupyter Notebook Markup Cell - Python
- How to upgrade pip/pip3 package installer for Python - PIP