Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 356
  • Last Modified:

Changing usertypes using batch file

Is there a way to change the active directory usertype using the command prompt.  I'd like to use this in a batch file.
Thanks,
0
VaughanC
Asked:
VaughanC
  • 3
  • 2
1 Solution
 
AntyraelCommented:
What exactly do you plan to change? Can you be more specific?
0
 
VaughanCAuthor Commented:
I have user access controlled by group policies.  I've just realised what I'm trying to do is to remove membership from one Global Security Group and add membership of another.  I'd like to do this with a batch file if possible.
Thanks,
0
 
AntyraelCommented:
If you can run the batch files on a domain controller, a server with adminpak installed (Windows Server 2003) or AD tools from Server 2008, you can use the dsquery and dsmod commands.

For example, the following command adds user with samaccountname bob to the sales group:
dsquery -samid bob | dsmod group "cn=Power Users,cn=Users,dc=intra,dc=net" -addmbr

To remove the same user from a group, use:
dsquery -samid bob | dsmod group "cn=Power Users,cn=Users,dc=intra,dc=net" -rmmbr

You can use different search parameters instead of the samaccountname, try dsquery /? for more information.
0
 
AntyraelCommented:
Correction, that was not the sales group, obviously, it was the Power users group ;)
0
 
VaughanCAuthor Commented:
Thanks for that.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now