Check OU contains Users or Computers Objects

Welcome Forums General PowerShell Q&A Check OU contains Users or Computers Objects

  • This topic has 1 reply, 2 voices, and was last updated 1 year ago by
    Senior Moderator
    .
Viewing 1 reply thread
  • Author
    Posts
    • #161541
      Participant
      Topics: 2
      Replies: 0
      Points: 23
      Rank: Member

      Hello everyone,

      I have an OU name. How Can check if specific OU contains Users or Computer Objects,

      via LDAP query?

       

      edit:

      I should remove an organizational unit if it does not contains users or computer objects

       

      Thanks

       

    • #161561
      Senior Moderator
      Topics: 9
      Replies: 1236
      Points: 4,443
      Helping Hand
      Rank: Community Hero

      Assuming this as not a scrip request.

      You can use Get-ADObject targeting an OU and use Where-Object to filter by objectcategory.

      https://docs.microsoft.com/en-us/powershell/module/addsadministration/get-adobject?view=win10-ps

      PS: I’ve posted this without testing.

Viewing 1 reply thread
  • The topic ‘Check OU contains Users or Computers Objects’ is closed to new replies.