I'm using the following script to compile a list of users and their login scripts. This helps us identify which login scripts are being used and also finding any users who don't have a login script assigned. Here's the script: code:
Break ON
$target = GetObject("LDAP://OU=Users,OU=USA,DC=mycompany,DC=net")
If ReDirectOutput("c:\logons.xls") = 0
For Each $user in $target
$script = $user.loginscript
If $Script = ""
? "Current Script for"+Chr(09)+$user.name+Chr(09)+ "NO SCRIPT ASSIGNED"
Else
? "Current Script for "+Chr(09)+$user.name+Chr(09)+$script
EndIf
Next
EndIf
The script works great to retrieve the users from the OU specified. The problem is, under the OU "USA" there are sub OU's for almost every state and then each of those has one or more sub OU's containing user IDs. Is there anyway to have the script search all sub OU's underneath any given "root" OU and return the same info? I know that I could hard code an array of target OU's and loop through that, but we're talking about possibly 100's of OU's and 1000's of users.
Thanks.