Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

only the samaccount name for the group members and not the distinguishedname

$
0
0

Hello,

Do you have a solution in my script to get only the samaccountname and not the distinguishedname of group members.

Function HOgroup

{

$Group = Read-Host "Choose your group"
$domainLDAP = [ADSI]''
$ObjRecherche = New-Object System.DirectoryServices.DirectorySearcher($domainLDAP)
$objRecherche.Filter ="(&(objectClass=group)(Name=$Group)(description=*))"
$ObjResult = $ObjRecherche.findall()

#Récupération du DistinguishedName et la description#

foreach ($result in $objResult)

{

$groupEntry = $result.getdirectoryentry()

$groupDN = $groupEntry.distinguishedName
$groupDesc = $groupEntry.description
$Connexion = [ADSI]"LDAP://$groupDN"
$Groupmember = $Connexion.member

Write-Host "`n`nLe garant pour ce groupe du domaine HO est : "$groupEntry.description" `n`nAttention, il s'agit de l'information du champ description."
Write-Host "`n`n Les membres de votre groupes sont : `n`n"$Groupmember""
}
}
HOGroup


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>