Get user logon name (UPN), SID,OU membership from account name.
If you only have name as your info and you want to get other infos such as SID, UPN, OU membership and other details. A correct name should be good enough to get more details from PowerShell.
Code below will get this output:
- Get user SID
- Get user UPN or user logon name
- Get user Full Name
- Get user OU membership
=======================================
#set the user name to be queried
$user="Juan Karlos"
#code below will display the name and samaccountname
#$userinfo = Get-ADUser -Filter "Name -eq '$user'" | Select-Object name, samaccountname
#code below will display only the value or the samaccountname without the header
#-ExpandProperty will hide the header
$userinfo = Get-ADUser -Filter "Name -eq '$user'" | Select-Object -ExpandProperty samaccountname
#Display more details about the user information
Get-aduser -Identity $userinfo
#Display the output on the console
write-host $userinfo
=======================================
Cheers... Hope it helps..
If you only have name as your info and you want to get other infos such as SID, UPN, OU membership and other details. A correct name should be good enough to get more details from PowerShell.
Code below will get this output:
- Get user SID
- Get user UPN or user logon name
- Get user Full Name
- Get user OU membership
=======================================
#set the user name to be queried
$user="Juan Karlos"
#code below will display the name and samaccountname
#$userinfo = Get-ADUser -Filter "Name -eq '$user'" | Select-Object name, samaccountname
#code below will display only the value or the samaccountname without the header
#-ExpandProperty will hide the header
$userinfo = Get-ADUser -Filter "Name -eq '$user'" | Select-Object -ExpandProperty samaccountname
#Display more details about the user information
Get-aduser -Identity $userinfo
#Display the output on the console
write-host $userinfo
=======================================
Cheers... Hope it helps..
Comments
Post a Comment