I was recently asked how to add user information – specifically first and last name – into computer description in Active Directory.
First get your user
$user = Get-ADUser -Identity FredBrown
Then add the information to the computer’s description
Set-ADComputer -Identity W10ProIp -Description “Used by $($user.Givenname) $($user.Surname)”
You need to use the subexpression – $() – syntax to resolve the values rather than getting references to the $user object.
Then test the description has been set
Get-ADComputer -Identity W10ProIp -Properties Description
If it was me I’d add the samAccountName or other unique identifier as name isn’t sufficient to uniquely identify the user