kili Posted February 9, 2011 Posted February 9, 2011 Hi can you help. I have a VBS script below which updates the user account “log on to” properties in Active directory. Basically the script adds computers that the user can log on too. However as we have over 400 PC’s but we only want them to have access to 300 of them it will take some time to add the 300 in the form"COMPS300, COMPS172, COMPS173" I realise this can be done via a GPO but this is not needed in this instance. I’m not a script writer so not sure how to amend this. I assume some sort of wild card or loop statement is needed . Any advice would be greatly appreciated Set objUser = GetObject _ ("LDAP://cn=test,ou=2006,ou=Students,ou=users,ou=School Resources,dc=anyname,dc=domain,dc=local") objUser.Put "userWorkstations", "COMPS300, COMPS172, COMPS173" objUser.SetInfo Regards Kili
LosOjos Posted February 9, 2011 Posted February 9, 2011 Does the naming structure allow for a range to be used theoretically? i.e. your computers are name COMPS001 to COMPS400, and you only want them to have access from COMPS001 to COMPS300? 1
kili Posted February 9, 2011 Author Posted February 9, 2011 Does the naming structure allow for a range to be used theoretically? i.e. your computers are name COMPS001 to COMPS400, and you only want them to have access from COMPS001 to COMPS300? Thank you for your reply LosOjos. Yes I only want users to have access to a range of computers between COMPS001 to COMPS300. Regards Kili
LosOjos Posted February 9, 2011 Posted February 9, 2011 Build up the relevant string with a for loop, like so: Set objUser = GetObject _ ("LDAP://cn=test,ou=2006,ou=Students,ou=users,ou=School Resources,dc=anyname,dc=domain,dc=local") sWorkstations = "" For x=1 to 300 sX = right("00" & Str$(x), 3) 'Builds the string representation of x with leading zeroes sWorkstations = sWorkstations & "COMPS" & sX & "," 'appends sWorkstations for use later on Next x sWorkstations = left(sWorkstations, len(sWorkstations) - 1) 'removes final comma objUser.Put "userWorkstations", sWorkstations objUser.SetInfo
kili Posted February 9, 2011 Author Posted February 9, 2011 Build up the relevant string with a for loop, like so: Set objUser = GetObject _ ("LDAP://cn=test,ou=2006,ou=Students,ou=users,ou=School Resources,dc=anyname,dc=domain,dc=local") sWorkstations = "" For x=1 to 300 sX = right("00" & Str$(x), 3) 'Builds the string representation of x with leading zeroes sWorkstations = sWorkstations & "COMPS" & sX & "," 'appends sWorkstations for use later on Next x sWorkstations = left(sWorkstations, len(sWorkstations) - 1) 'removes final comma objUser.Put "userWorkstations", sWorkstations objUser.SetInfo Many Thanks LosOjos much appreciated. I'll give it a shot and see what happens Cheers Kili
Arthur Posted February 9, 2011 Posted February 9, 2011 Adding 300 computers to the 'userWorkstations' attribute in AD probably won't work because the maximum number you can add is 64 according to Microsoft... http://support.microsoft.com/kb/938458 1
PiqueABoo Posted February 9, 2011 Posted February 9, 2011 I can believe that would cause trouble without troubling to read the KB. Offhand a better approach might be to make some AD group e.g. "Restricted Logon" and deny logon locally for that group on COMPS301 upwards.
kili Posted February 10, 2011 Author Posted February 10, 2011 Piqaboo, thank you for the reply but I did say I realise this can be done via a GPO but this is not needed in this instance. Arthur thank you for the heads up , obviously an issue. LosOjos thank you for all your help
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now