I’m trying to come up with a way to get a display or friendly name for a local user logged into their PC. This is part of a larger project, and I need to be able to write some basic information to a database.
Here’s what I have so far. I cannot for the life of me figure out what I am doing wrong. I am assuming it is a syntax error, as it works when I feed it information rather than a variable.
$user = whoami /upn
#Get-ADUser -Filter ‘EmailAddress -eq “$user”’ | Select Name | ft -HideTableHeaders
Get-ADUser -Filter ‘EmailAddress -eq “firstname.lastname@example.org”’ | Select Name | ft -HideTableHeaders