I found it:

[Environment]::UserName
$Env:UserName

There is also:

$Env:UserDomain
$Env:ComputerName
Answer from Thomas Bratt on Stack Overflow
🌐
Reddit
reddit.com › r/powershell › get current user display name
r/PowerShell on Reddit: Get current user display name
December 17, 2021 -

Trying to get it current user name display name without using active directories is it possible?

For now I’m Using

$appuser = (get-aduser ($env:username)).name

But I’m trying to find a way without using the ADuser

Discussions

How to get the user's displayName when using PowerShell 2.0 and the Active Directory module is not present?
I’ve tried all kinds of things to get the user’s displayName from AD inside of PowerShell 2.0 but can’t seem to find something that works. The majority of computers will not have the Active Directory module installed and there are still some PowerShell versions below 5.1 with the lowest ... More on forums.powershell.org
🌐 forums.powershell.org
4
0
December 19, 2023
How to make my powershell script reference the current user account who is running it?
Use [Environment]::UserName to get the name of the user who is running the script. This doesn't use env vars but actually inspects the access token of the current thread. More on reddit.com
🌐 r/PowerShell
20
38
September 26, 2022
Get current user on local machine using Powershell - Stack Overflow
I need to retrieve the displayname / full name of the user currently logged in on the computer. Is there anyway to do this without using AD? ... Please take a look at this thread ("How to get current username in Windows Powershell?"). More on stackoverflow.com
🌐 stackoverflow.com
Get the "friendly" name for logged-in User (AD)
$Search = [adsisearcher]"(SamAccountName=$env:USERNAME)" $DisplayName = $Search.FindOne().Properties.displayName $DisplayName More on reddit.com
🌐 r/PowerShell
9
4
April 1, 2014
🌐
MiniTool Partition Wizard
partitionwizard.com › home › partition manager › powershell get current username on windows 11/10/8/7 [full guide]
Advanced Guide: PowerShell Get Current Username on Windows
December 4, 2024 - Type PowerShell in the search box, and then right-click the Windows PowerShell and select Run as administrator. Then click on Yes to confirm it. In the pop-up window, type the following command and hit Enter to get the current logged-on user name.
🌐
PowerShell Forums
forums.powershell.org › powershell help
How to get the user's displayName when using PowerShell 2.0 and the Active Directory module is not present? - PowerShell Help - PowerShell Forums
December 19, 2023 - I’ve tried all kinds of things to get the user’s displayName from AD inside of PowerShell 2.0 but can’t seem to find something that works. The majority of computers will not have the Active Directory module installed and there are still some PowerShell versions below 5.1 with the lowest still present being 2.0. I’ve tried $adsysinfo = New-Object -ComObject "ADSystemInfo" $adsysinfo.GetType().InvokeMember("$($env:USERNAME)",$Null,$adsysinfo,$null) Which gives me + $adsysinfo.GetType().InvokeM...
🌐
ShellGeek
shellgeek.com › home › powershell tips › get current user name in powershell
Get Current User name in PowerShell - ShellGeek
April 14, 2024 - To get current user name in PowerShell, use whoami, GetCurrent() method of WindowsIdentity, $env or Get-WMIObject cmdlet in PowerShell.
🌐
SharePoint Diary
sharepointdiary.com › sharepoint diary › powershell › how to get the current user name in powershell?
How to Get the Current User Name in PowerShell? - SharePoint Diary
September 19, 2025 - If you just need the current user’s username, PowerShell provides a quick and easy way to get the currently logged-on user using the [Environment]::UserName method: ... This command pulls the username of the person logged in and stores it ...
Find elsewhere
🌐
YouTube
youtube.com › maozinhapontocom
How get current user display name from Powershell - YouTube
AboutPressCopyrightContact usCreatorsAdvertiseDevelopersTermsPrivacyPolicy & SafetyHow YouTube worksTest new featuresNFL Sunday Ticket · © 2024 Google LLC
Published   December 29, 2022
Views   1K
🌐
Reddit
reddit.com › r/powershell › how to make my powershell script reference the current user account who is running it?
r/PowerShell on Reddit: How to make my powershell script reference the current user account who is running it?
September 26, 2022 -

Part of my script involves making yourself a site admin for OneDrive data (set-spouser), then adding the manager, then removing yourself. Since I've always been the only one using this script, I've hardcoded my username into the script. However, other people will be using this script.

When it comes to connecting to exchange online or other admin portals, it's easy to do. You just leave the -userprincipalname field empty, and you get a popup box asking to enter your username, then your password. How do you "leave empty" which account you want to make a site admin for OneDrive data?

🌐
Stack Overflow
stackoverflow.com › questions › 33892134 › get-current-user-on-local-machine-using-powershell
Get current user on local machine using Powershell - Stack Overflow
@CanBilgin This only gives me the name of the computer instead of the name displayed when I open Start Menu. ... Like the Full Names I get from the command: Get-WmiObject -Class Win32_UserAccount. Although I want the current users full name :)
Top answer
1 of 1
1
Get Current User Name in PowerShell · You can easily get the current username in Windows PowerShell using whoami to return domain\username as below · There are also many ways to get the current logged on username in Windows PowerShell as the following: · Using System.Security.Principal.WindowsIdentity · Using $env · Using Win32_ComputerSystem · 1) Get current logged-on username in Windows PowerShell · [System.Security.Principal.WindowsIdentity]::GetCurrent().Name · This example helps you to get the current user who runs the PowerShell domain\username. so if you are run the Powershell as a different user it will get the current user who runs the PowerShell, not the currently logged-on user to the machine. · Output · 2) Get current logged-on username without domain in Windows PowerShell · [System.Security.Principal.WindowsIdentity]::GetCurrent().Name.split("\")[1] · Or · $env:UserName · This example helps you to get the current user who runs the PowerShell without domain. · 3) Get domain name in Windows PowerShell · [System.Security.Principal.WindowsIdentity]::GetCurrent().Name.split("\")[0] · $env:UserDomain #not recommened · This example helps you to get only the current domain name. · 4) Get current logged-on username to machine in PowerShell · $userInfo=((Get-WMIObject -class Win32_ComputerSystem | Select-Object -ExpandProperty username) -split '\\' ) $userInfo[0]+"\"+$userInfo[1] · This example helps you to get the logged-in user info like Domain Name $userInfo[0] and User Name $userInfo[1] or domain\username $userInfo[0]+"\"+$userInfo[1]. but if you are running the Powershell as a different user it will not get the current user who runs the PowerShell, it only gets the currently logged-on user to the machine. · See Also · Get all Groups a user is a member of Using PowerShell · PowerShell Get-Date in Short format
🌐
Adam the Automator
adamtheautomator.com › powershell-get-current-user
Using the Dynamic PowerShell to Get Current Users
The whoami command can also return the current user’s fully qualified distinguished name (FQDN) and the user principal name (UPN). This command output could be helpful if you intend to run a script that retrieves the current user’s identity ...
Published   October 6, 2022
🌐
Delft Stack
delftstack.com › home › howto › powershell › powershell get current user
How to Get Current User in PowerShell | Delft Stack
February 2, 2024 - For example, if you execute a script asking for user credentials, PowerShell can dynamically generate the username, leaving you with only the password to enter manually. We will use PowerShell cmdlets, namely Get-CimInstance and Get-WMIObject.
🌐
Reddit
reddit.com › r/powershell › get the "friendly" name for logged-in user (ad)
r/PowerShell on Reddit: Get the "friendly" name for logged-in User (AD)
April 1, 2014 -

I hate that I don't know the terminology for what I'm asking -- which is also probably why I can't find it on Google. When logged into my PC at work, using Active Directory, I can see my full name on my personal folder when I click on the Start Menu. But when I run something like, whoami, I just see my login (something like my first initial and last name.) How I can I get the prior?

🌐
Serveracademy
community.serveracademy.com › powershell
How to find User Logon Name by User Display Name in PowerShell - PowerShell - Server Academy Community Forum
May 3, 2022 - I have multiple display name of users in a csv file what should I do if I want to find their samaccount name and email address and from ad using PowerShell. and also a outcome if PowerShell cant find the user. we can do …
🌐
ManageEngine
manageengine.com › home › powershell › get ad user display name
Get AD-User Display Name | PowerShell Steps & Examples
October 13, 2025 - Delegated reporting: Securely delegate AD reporting tasks to help desk technicians without exposing them to sensitive data or complex PowerShell scripts. ... Run the following command to search for display names and include unique identifiers like SamAccountName or DistinguishedName: Copy Get-ADUser -Filter {DisplayName -eq "John Smith"} -Properties SamAccountName, DistinguishedName | Select-Object DisplayName, SamAccountName, DistinguishedName · 2. How do I get both display name and group memberships for AD users?
🌐
Powershell Commands
powershellcommands.com › powershell-get-current-user
PowerShell Get Current User: A Quick Guide
January 22, 2024 - One of the simplest ways to obtain the current user's name is by utilizing the `whoami` command. This command quickly displays the username of the person currently logged into the system.
🌐
Alkane Solutions
alkanesolutions.co.uk › home › msi application packaging › use powershell to get the current username and sid from an elevated session
Use PowerShell to get the Current Username and Sid from an Elevated Session | Alkane
April 5, 2023 - Here’s a quick example of how we can use PowerShell to get the current username and sid from an elevated session: $loggedInUser = Get-CimInstance –ClassName Win32_ComputerSystem | Select-Object @{Name = 'Username'; Expression = {$_.Username}}, @{Name = 'Sid'; Expression = {([System.Security.Principal.NTAccount]$_.UserName).Translate([System.Security.Principal.SecurityIdentifier]).Value}} write-host "Username is: " $loggedInUser.Username write-host "Sid is: " $loggedInUser.Sid
🌐
Eddie Jackson
eddiejackson.net › lab › 2023 › 12 › 19 › powershell-return-current-user-system-account
PowerShell – Return Current User – System Account – Lab Core | The Lab of MrNetTek
PS C:\WINDOWS\system32> whoami nt authority\system PS C:\WINDOWS\system32> $qwinstaOutput = & qwinsta >> >> $currentUserName = $null >> >> foreach ($line in $qwinstaOutput) { >> if ($line -match '^>\s*\S+\s+(\S+)') { >> $currentUserName = $matches[1] >> break >> } >> } >> >> Write-Host "Currently Logged-in User: $currentUserName" Currently Logged-in User: Demo99 PS C:\WINDOWS\system32>