Question [RESOLU]affichage requete AD
- Dji_c
- Auteur du sujet
- Hors Ligne
- Nouveau membre
Réduire
Plus d'informations
- Messages : 4
- Remerciements reçus 0
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
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.
- Dji_c
- Auteur du sujet
- Hors Ligne
- Nouveau membre
Réduire
Plus d'informations
- Messages : 4
- Remerciements reçus 0
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=\"(&(objectcategory=person)(objectclass=user))\"
$searcher.pageSize=1000
$searcher.PropertiesToLoad.Add(\"cn\"«»)
$searcher.PropertiesToLoad.Add(\"useraccountcontrol\"«»)
$searcher.PropertiesToLoad.Add(\"samaccountname\"«»)
$users = $searcher.FindAll()| where {$_.properties.cn -notmatch \"adm_*\" }| 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)}| sort @{expression={$_.Properties.samaccountname};Descending=$true}
$statusBar1.text=\"Pret\"
$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]
[code:1]
$searcher = new-object System.DirectoryServices.DirectorySearcher
$searcher.Filter=\"(&(objectcategory=person)(objectclass=user))\"
$searcher.pageSize=1000
$searcher.PropertiesToLoad.Add(\"cn\"«»)
$searcher.PropertiesToLoad.Add(\"useraccountcontrol\"«»)
$searcher.PropertiesToLoad.Add(\"samaccountname\"«»)
$users = $searcher.FindAll()| where {$_.properties.cn -notmatch \"adm_*\" }| 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)}| sort @{expression={$_.Properties.samaccountname};Descending=$true}
$statusBar1.text=\"Pret\"
$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
- Vous êtes ici :
- Accueil
- forum
- PowerShell
- Entraide pour les initiés
- [RESOLU]affichage requete AD