locked
Manage AD with Powershell RRS feed

  • Question

  • I want to list all groups with their group members in AD without AD module installed.

    NOTE::wmi commands preferred and I am working on a member server.

    Saturday, February 11, 2017 6:09 AM

Answers

  • THat is very old code which doesn't work.

    To get all groups we only need to do this:

    ([adsisearcher]'objectclass=group').FindAll() |
    	 select @{ n = 'Name'; e = { $_.Properties['name'] } },
    			@{ n = 'Member'; e = { $_.Properties['member'] } }


    \_(ツ)_/

    Saturday, February 11, 2017 10:34 AM

All replies

  • You can find code examples here;


    \_(ツ)_/

    Saturday, February 11, 2017 7:09 AM
  • Hi Sunita,

    Try below command to get add group members in AD without AD module 

    Mark this reply as answer if it is helpful.

    $objdomain = New-Object System.DirectoryServices.DirectoryEntry("LDAP://$($env:USERDOMAIN)")
    $objsearcher = New-Object System.DirectoryServices.DirectorySearcher
    $filter = "(Objectclass=group)"
    $objsearcher.SearchRoot = $objdomain
    $objsearcher.Filter = $filter
    $objsearcher.SearchScope = "Subtree"
    $colProplist = "name","Member"
    foreach ($i in $colPropList){$objSearcher.PropertiesToLoad.Add($i)}
    $colResults = $objSearcher.FindAll() | select -First 10
    foreach ($objResult in $colResults)
    {$objItem = $objResult.Properties; $objItem.name;$objItem.member}

    • Proposed as answer by SachinWaghmare Saturday, February 11, 2017 9:53 AM
    • Unproposed as answer by Bill_Stewart Sunday, February 12, 2017 2:03 PM
    Saturday, February 11, 2017 9:53 AM
  • THat is very old code which doesn't work.

    To get all groups we only need to do this:

    ([adsisearcher]'objectclass=group').FindAll() |
    	 select @{ n = 'Name'; e = { $_.Properties['name'] } },
    			@{ n = 'Member'; e = { $_.Properties['member'] } }


    \_(ツ)_/

    Saturday, February 11, 2017 10:34 AM