Append to userWorkstations using text list of usernames


  • Hello,

    I need to find a way to add our new proxy devices to the "Allowed to log on to..." or userWorkstations attribute.  I have a .txt file with the list of user names.  They need to be appended to the list as to maintain whatever is currently in the list.

    These users are spread throughout many OUs, so having an OU based script won't work for my needs.

    So basically:
    Is there a way through PS (or VBS) to append workstations to a user's account from a txt based list? 

    *Edit* So far all of the scripts I've been able to locate are based on applying to users within a specified OU. It will also be the same 3 workstations being added to each user.  That part can be static within the script.

    Thank you for your help


    • Edited by DevinK Monday, August 05, 2013 8:01 PM Additional information.
    Monday, August 05, 2013 7:56 PM


  • Hi Devin,

    Give this a try:

    Get-Content .\users.txt | ForEach {
        $workStations = (Get-ADUser $_ -Properties userWorkstations).userWorkstations
        $workStations += ",newPC1,newPC2,newPC3"
        Set-ADUser $_ -Replace @{userWorkstations=$workStations}

    EDIT: As always, make sure you test this on a small group first.

    Don't retire TechNet!

    Monday, August 05, 2013 8:52 PM