Hi All,
I want to search through the AD and count users in certain OU's.
Therefore I want to use loops to go through the directory tree to the destination OU's.
I tried it with this function but the result is ridiculous:
PS AD:\OU=muster,DC=muster,DC=net> foreach ($i.name in $rootous) { echo "ou=$i.Name" }
ou=@{Name=31}.Name
ou=@{Name=32}.Name
ou=@{Name=33}.Name
ou=@{Name=34}.Name
ou=@{Name=35}.Name
When I write the loop as follows, the result itself is fine:
foreach ($i.name in $rootous) { echo $i.Name }
31
32
33
34
35
At the end I thought about this rough loops to go through the directory tree:
[array]$rootous=ls | select "Name"
foreach ($i.name in $rootous)
{
cd “OU=$i.name”
[array]$subdir=ls | select "Name"
foreach (...) {...}
cd ..
}
Does anyone have an idea why this @{name.. is added to the string sometimes and sometimes not?
thx
cr