trying to pull attributes from get-aduser

Welcome Forums General PowerShell Q&A trying to pull attributes from get-aduser

Viewing 2 reply threads
  • Author
    Posts
    • #217074
      Participant
      Topics: 2
      Replies: 3
      Points: 71
      Rank: Member

      Hi – trying to understand how I can add a field from User attributes (employeeID) to this but can’t seem to figure out the correct syntax. Here’s what I have:

      Import-Module ActiveDirectory
      Get-ADUser -filter {Enabled -eq $True -and PasswordNeverExpires -eq $False} –Properties SamAccountName,mail,DistinguishedName,pwdLastSet,msDS-UserPasswordExpiryTimeComputed,CanonicalName |
      Select SamAccountName,mail,DistinguishedName,
      @{L="OU";E={($_.CanonicalName -split '/')[0..((($_.CanonicalName -split '/').count) - 2)] -join '/'}},
      @{L="Password Last Set"; E={[datetime]::FromFileTime($_."pwdLastSet")}},
      @{L="Password Expiry Date";E={[datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")}} | 
      Export-CSV "C:\temp\PasswordExpirationReportv3.csv" -NoTypeInformation -Encoding UTF8
    • #217101
      Participant
      Topics: 4
      Replies: 2231
      Points: 5,414
      Helping Hand
      Rank: Community MVP

      EmployeeID does not belong to the default attribute set Get-ADUser returns. You will have to specify it along with the other properties you already have for your parameter -Properties.

      …. and – of course – select it with your Select-Object. 😉

    • #217437
      Participant
      Topics: 2
      Replies: 3
      Points: 71
      Rank: Member

      EmployeeID does not belong to the default attribute set Get-ADUser returns. You will have to specify it along with the other properties you already have for your parameter -Properties.

      …. and – of course – select it with your Select-Object. 😉

      Thanks Olaf !

Viewing 2 reply threads
  • You must be logged in to reply to this topic.