1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
"compte;uid" > D:\Script_Fonc_a_valid\test\compte-UID.csv
[void][system.Reflection.Assembly]::LoadWithPartialName('System.windows.forms')
[void][reflection.assembly]::loadwithpartialname('System.drawing')
$Root1 = New-Object DirectoryServices.DirectoryEntry
# Create a selector and start searching from the Root of AD
$selector1 = New-Object DirectoryServices.DirectorySearcher
$selector1.SearchRoot = $root1
# Filter the users with -like "CN=Person*". Note the ForEach loop
$adobj1= $selector1.findall() `
| where {$_.properties.objectcategory -like "CN=Person*"}
ForEach ($person1 in $adobj1)
{
$prop1= $($person1.properties.samaccountname)
[int]$prop21= $($person1.properties.uidnumber)
#if ($prop2 -ne "0") {
"$prop1;$prop21" >> D:\Script_Fonc_a_valid\test\compte-UID.csv
} |