Add user to workstation group

From WPKG | Open Source Software Deployment and Distribution
Jump to: navigation, search

Here is how to add a local or domain user to a local workstation group such as "Remote Desktop Users"

My example package is for adding an active directory or domain user but you can add a local workstation user by not prefixing the "domain\". However, in order to add a domain user the system must be attached to the network at the time of WPKG running otherwise you will get the following error: System error 1789 has occurred. The trust relationship between this workstation and the primary domain failed.

 <package id="RDP-JoePublic"
        name="Add Joe Public to local machine for RDP"
        revision="%version%"
        reboot="false"
        priority="1">
        <variable name="version" value="1"/>
        <install cmd='%comspec% /c net localgroup "Remote Desktop Users" domain\userjp  /add'/>
        <remove cmd='%comspec% /c net localgroup "Remote Desktop Users" domain\userjp  /delete'> <exit code='2'/></remove>
 </package>