Question [RESOLU]affichage requete AD

Plus d'informations
il y a 14 ans 6 mois #5353 par Dji_c
[RESOLU]affichage requete AD a été créé par Dji_c
Bonjour,

J'ai fait un petit script qui fonctionne à la perfection sauf qu'il ne gère pas les comptes homonymes de mon AD!
Je souhaiterai modifier mon script pour que dans la liste au lieu d'afficher les cn on ressorte les sAMAccountName, mais après multiple recherches et tests je ne parviens pas a trouver la solution.

Auriez vous une idée ?

[code:1]
$searcher=New-Object DirectoryServices.DirectorySearcher
$searcher.Filter=\"(&(objectcategory=person)(objectclass=user))\"
$searcher.pageSize=1000
$users=$searcher.FindAll()| where {$_.properties.cn -notmatch \"IUSR_*\" }| where {$_.properties.cn -notmatch \"IWAM_*\" }| where {$_.properties.cn -notmatch \"Invité\" }| where {$_.properties.cn -notmatch \"user_*\" }| where {$_.properties.cn -notmatch \"tmersrvd\" }| where {$_.properties.cn -notmatch \"test \" }| where {$_.properties.cn -notmatch \"test_\" }| where {$_.properties.cn -notmatch \"tecia\" }| where {$_.properties.cn -notmatch \"srv_\" }| where {$_.properties.cn -notmatch \"reseau scan\" }| where {$_.properties.cn -notmatch \"Modèle\" }| where {$_.properties.cn -notmatch \"master\" }| where {$_.properties.cn -notmatch \"krbtgt\" }| where {$_.properties.cn -notlike \"*$*\" }| where {$_.properties.cn -notmatch \"tec_\" }| where {($_.properties.useraccountcontrol -ne 514)}
$users | Foreach-Object {
if ([string]::isNullOrEmpty($_.properties.employeeid)) { $_.path } }

$i=0
if ($users) {
$users | foreach {
$listUsers.Items.add($_.Properties.cn[0])
$i++
$progressBar1.value=($i/$users.count) * 100
}

[/code:1]<br><br>Message édité par: Dji_c, à: 7/10/09 13:43

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 14 ans 6 mois #5442 par Dji_c
Réponse de Dji_c sur le sujet Re:[RESOLU]affichage requete AD
Pb résolu de cette manière :

[code:1]
$searcher = new-object System.DirectoryServices.DirectorySearcher
$searcher.Filter=\&quot;(&amp;(objectcategory=person)(objectclass=user))\&quot;
$searcher.pageSize=1000
$searcher.PropertiesToLoad.Add(\&quot;cn\&quot;«»)
$searcher.PropertiesToLoad.Add(\&quot;useraccountcontrol\&quot;«»)
$searcher.PropertiesToLoad.Add(\&quot;samaccountname\&quot;«»)
$users = $searcher.FindAll()| where {$_.properties.cn -notmatch \&quot;adm_*\&quot; }| where {$_.properties.cn -notmatch \&quot;IUSR_*\&quot; }| where {$_.properties.cn -notmatch \&quot;IWAM_*\&quot; }| where {$_.properties.cn -notmatch \&quot;Invité\&quot; }| where {$_.properties.cn -notmatch \&quot;user_*\&quot; }| where {$_.properties.cn -notmatch \&quot;tmersrvd\&quot; }| where {$_.properties.cn -notmatch \&quot;test \&quot; }| where {$_.properties.cn -notmatch \&quot;test_\&quot; }| where {$_.properties.cn -notmatch \&quot;tecia\&quot; }| where {$_.properties.cn -notmatch \&quot;srv_\&quot; }| where {$_.properties.cn -notmatch \&quot;reseau scan\&quot; }| where {$_.properties.cn -notmatch \&quot;Modèle\&quot; }| where {$_.properties.cn -notmatch \&quot;master\&quot; }| where {$_.properties.cn -notmatch \&quot;krbtgt\&quot; }| where {$_.properties.cn -notlike \&quot;*$*\&quot; }| where {$_.properties.cn -notmatch \&quot;tec_\&quot; }| where {($_.properties.useraccountcontrol -ne 514)}| sort @{expression={$_.Properties.samaccountname};Descending=$true}

$statusBar1.text=\&quot;Pret\&quot;
$users | Foreach-Object {
if ([string]::isNullOrEmpty($_.properties.employeeid)) { $_.path } }

$i=0
if ($users) {
$users | foreach {
$listUsers.Items.add(($_.Properties.samaccountname[0]).ToUpper())
$i++
$progressBar1.value=($i/$users.count) * 100
}
[/code:1]

Connexion ou Créer un compte pour participer à la conversation.

Temps de génération de la page : 0.062 secondes
Propulsé par Kunena