I have several OUs I want to search, some of them nested. the searchscope doesn't seem to be running as I expect from the documentation.
As in my example ablove, I assume this script should search just the ADname/americas/finance OU and output a list of the users that have no login script with their homedrive and homefolder entries.
With the base argument added to the -searchscope, I get no results, when I know that there is a user with no login script in the finance OU. If I leave it off or put in onelevel or subtree it works. I also have users in the americas OU that will show up, but I want to keep those as a separate report.
Am I just misunderstanding the -searchscope syntax?
-SearchScope <SearchScope> Specify one of these parameter values:
'Base' Limits the search to the base (SearchRoot) object. The result contains a maximum of one object. 'OneLevel' Searches the immediate child objects of the base (SearchRoot) object, excluding the base object. 'Subtree' Searches the whole sub-tree, including the base (SearchRoot) object and all its child objects.
So if you want to get users from your OU without any sub-OUs, use 'OneLevel' scope