How to get the Get-ADGroup users list from LDAP (PowerShell cmdlet) in windows

Viewed 54

How to get AD-group users list from LDAP using PowerShell without username and password.

Get-ADGroup -LDAPFilter (&(objectCategory=group)((cn=Testgrp")))) 

I am trying this way but not fixing can anyone please help me out?

Right now I'm able to get the AD-Group info by using the below PowerShell scripts.

Get the group Info:

Get- ADGroupMember -Identify TEST_GRP_NM | select distinguishName | ft

Get-AdUser -filter{Name -like "GROUP_NM"} -Properties *

Get the user info:

Get-AdUser -Server "DOMAIN" -Identify "NTID" -Properties MemberOf

Note: Need to achieve the list of users from the LDAP group without using LDAP username and password

1 Answers

I personnally use this script to crawl through the AD (from another StackOverFlow question) In case it becomes somehow a broken link:


# Your filter
$Filter = "(&(objectCategory=group)((cn=Testgrp))))"

# The path you want to scan
$RootOU = "OU=AnotherOU,OU=AnOU,DC=etc,DC=Something"

# The scope Base, One-level or Subtree
# The name is explicit enough
$Scope = "subtree"

# Instanciation and configuration of the directory searcher
$Searcher = New-Object System.DirectoryServices.DirectorySearcher
$Searcher.SearchRoot = New-Object System.DirectoryServices.DirectoryEntry("LDAP://$($RootOU)")
$Searcher.Filter = $Filter
$Searcher.SearchScope = $Scope

# Getting results from the AD
# A first pipe to get the member property returning a list of member
# A second pipe to display each member of the list in a line
$Searcher.FindAll() | Foreach-Object {$($_.Properties["member"])} | Foreach-Object {"$($_)`n"}

Hope it helps !

Related