Get-ADObject not showing enabled AD Object result?

Welcome Forums General PowerShell Q&A Get-ADObject not showing enabled AD Object result?

Viewing 5 reply threads
  • Author
    Posts
    • #251060
      Participant
      Topics: 27
      Replies: 28
      Points: 250
      Rank: Participant

      People,

      I need some help in explaining and modifying the below script, as to why the below script is not returning any result at all.

      But when the section Enabled -eq $true is removed, all objects is returned?

       

    • #251108
      Participant
      Topics: 0
      Replies: 77
      Points: 343
      Helping Hand
      Rank: Contributor

      Get-ADObject does not output an Enabled property for user and computer accounts. If you use Get-ADUser or Get-ADComputer, you get that property.

      You could instead attempt to look at the UserAccountControl attribute. The second bit (decimal 2) will be on for disabled accounts.

       

    • #251129
      Participant
      Topics: 27
      Replies: 28
      Points: 250
      Rank: Participant

      Wow, this is cool and working.

      thanks @admin

    • #251135
      Participant
      Topics: 27
      Replies: 28
      Points: 250
      Rank: Participant

      What about using this pipe:

      | Where-Object {@(‘user’, ‘computer’) -contains $_.objectClass}

      Would it be faster or more accurate?

    • #251141
      Participant
      Topics: 0
      Replies: 77
      Points: 343
      Helping Hand
      Rank: Contributor

      -Filter is almost always faster than piping to Where. This is especially true for indexed AD attributes. There are cases where the where() method is faster if you use a favorable mode for the situation.

    • #251144
      Participant
      Topics: 27
      Replies: 28
      Points: 250
      Rank: Participant

      -Filter is almost always faster than piping to Where. This is especially true for indexed AD attributes. There are cases where the where() method is faster if you use a favorable mode for the situation.

      Thank you so much for the explanations 🙂

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