title: How To Get Get-ADUser To Return Individual Properties
body: <p>I'm trying to clean up this code.  Isn't there a way to do something like this?</p>
  
  <pre><code>$CurrentUserDetails = Get-ADuser -Identity $CurrentUserName -Properties *
  $CurrentUserDetails.LastName (&lt;-- This does not work.)
  </code></pre>
  
  <p>Instead of having to do this? (The below works)</p>
  
  <pre><code>$CurrentFirstName = (Get-ADuser -Identity $CurrentUserName -Properties GivenName).GivenName
  $CurrentLastName = (Get-ADuser -Identity $CurrentUserName -Properties SurName).SurName
  $CurrentDisplayName = (Get-ADuser -Identity $CurrentUserName -Properties DisplayName).DisplayName
  $CurrentDistinguishedName = (Get-ADuser -Identity $CurrentUserName -Properties DistinguishedName).DistinguishedName
  $CurrentUserPrincipalName = (Get-ADuser -Identity $CurrentUserName -Properties UserPrincipalName).UserPrincipalName
  </code></pre>