Here's one way to get the direct members of an AD group without using the AD cmdlets:
param( [Parameter(Mandatory)] $GroupName ) $ADS_ESCAPEDMODE_ON = 2 $ADS_SETTYPE_DN = 4 $ADS_FORMAT_X500 = 5 function Invoke-Method { param( [__ComObject] $object, [String] $method, $parameters ) $output = $object.GetType().InvokeMember($method,"InvokeMethod",$null,$object,$parameters) if ( $output ) { $output } } function Set-Property { param( [__ComObject] $object, [String] $property, $parameters ) [Void] $object.GetType().InvokeMember($property,"SetProperty",$null,$object,$parameters) } $Pathname = New-Object -ComObject "Pathname" Set-Property $Pathname "EscapedMode" $ADS_ESCAPEDMODE_ON $Searcher = [ADSISearcher] "(&(objectClass=group)(name=$GroupName))" $Searcher.PropertiesToLoad.AddRange(@("distinguishedName")) $SearchResult = $searcher.FindOne() if ( $SearchResult ) { $GroupDN = $searchResult.Properties["distinguishedname"][0] Invoke-Method $Pathname "Set" @($GroupDN,$ADS_SETTYPE_DN) $Path = Invoke-Method $Pathname "Retrieve" $ADS_FORMAT_X500 $Group = [ADSI] $path foreach ( $MemberDN in $Group.member ) { Invoke-Method $Pathname "Set" @($MemberDN,$ADS_SETTYPE_DN) $Path = Invoke-Method $Pathname "Retrieve" $ADS_FORMAT_X500 $Member = [ADSI] $Path "" | Select-Object ` @{ Name="group_name" Expression={$Group.name[0]} }, @{ Name="member_objectClass" Expression={$member.ObjectClass[$Member.ObjectClass.Count - 1]} }, @{ Name="member_sAMAccountName"; Expression={$Member.sAMAccountName[0]} } } } else { throw "Group not found" }
This version uses the Pathname COM object to handle name escaping and outputs the the object class and sAMAccountName for each member of the group.
net groupcommand. If it is just theget-adgroupmembercmdlet you can't use you can always try the Quest cmdletsGet-ADGroupMemberWhy?