I want to list all sub-ou's in an OU. I found this VBS on the script center:
Code:
Set objOU = GetObject("LDAP://ou=one,ou=two,dc=corp,dc=ads")
objOU.Filter = Array("organizationalUnit")
strList = "Select an Organizational Unit:"
For Each objChild In objOU
strList = strList & vbCrLf & objChild.ou
Next
strSelect = InputBox(strList, "MyProgram")
And came up with this KiXtart equivalent:
Code:
$Filter[0] = "organizationalUnit"
$objOU = GetObject("LDAP://ou=one,ou=two,dc=corp,dc=ads")
$objOU.Filter = $Filter
For Each $objChild in $objOU
? $objChild.name
Next
When I run my KiXtart though, it returns everything in the OU, Sub-OU's, and computers in that OU as well. So it appears as though I am not setting up the filter properly. Can anyone see an obvious error in this small snippet? I don't know the filter method all that well, or why I would be using it with an array