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