+ Post New Thread
Results 1 to 8 of 8
Scripts Thread, Log on to specific computers in Coding and Web Development; Hi can you help. I have a VBS script below which updates the user account “log on to” properties in ...
  1. #1

    Join Date
    Jun 2010
    Posts
    198
    Thank Post
    9
    Thanked 25 Times in 24 Posts
    Rep Power
    21

    Log on to specific computers

    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


    Code:
    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

  2. #2

    LosOjos's Avatar
    Join Date
    Dec 2009
    Location
    West Midlands
    Posts
    5,447
    Thank Post
    1,438
    Thanked 1,168 Times in 797 Posts
    Rep Power
    707
    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?

  3. Thanks to LosOjos from:

    kili (9th February 2011)

  4. #3

    Join Date
    Jun 2010
    Posts
    198
    Thank Post
    9
    Thanked 25 Times in 24 Posts
    Rep Power
    21
    Quote Originally Posted by LosOjos View Post
    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

  5. #4

    LosOjos's Avatar
    Join Date
    Dec 2009
    Location
    West Midlands
    Posts
    5,447
    Thank Post
    1,438
    Thanked 1,168 Times in 797 Posts
    Rep Power
    707
    Build up the relevant string with a for loop, like so:

    Code:
    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

  6. #5

    Join Date
    Jun 2010
    Posts
    198
    Thank Post
    9
    Thanked 25 Times in 24 Posts
    Rep Power
    21
    Quote Originally Posted by LosOjos View Post
    Build up the relevant string with a for loop, like so:

    Code:
    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

  7. #6


    Join Date
    Feb 2007
    Location
    51.405546, -0.510212
    Posts
    8,760
    Thank Post
    221
    Thanked 2,630 Times in 1,938 Posts
    Rep Power
    779
    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

  8. Thanks to Arthur from:

    kili (10th February 2011)

  9. #7

    Join Date
    Jan 2006
    Location
    Surburbia
    Posts
    2,178
    Thank Post
    74
    Thanked 307 Times in 243 Posts
    Rep Power
    115
    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.

  10. #8

    Join Date
    Jun 2010
    Posts
    198
    Thank Post
    9
    Thanked 25 Times in 24 Posts
    Rep Power
    21
    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

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 15
    Last Post: 24th November 2009, 11:17 AM
  2. clear old cookies on log off (or log on)
    By ZeroHour in forum Scripts
    Replies: 0
    Last Post: 4th November 2008, 09:32 AM
  3. Can log on Local can't log on to domain
    By speckytecky in forum Network and Classroom Management
    Replies: 16
    Last Post: 25th April 2008, 12:05 PM
  4. Replies: 1
    Last Post: 7th September 2007, 02:16 PM
  5. Blocking Specific Pages
    By Michael in forum Windows
    Replies: 4
    Last Post: 11th February 2006, 03:06 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •