Richard Parmiter

Virtualisation blog and Knowledge Base

  • You are here: 
  • Home
  • dsquery

How to export the users of an AD Group.

Posted on January 23rd, 2009

This is the best and fastest way to export all users who are members of a group

dsquery group “CN=Group Name,OU=OU Location,DC=Domain Name,DC=local” | dsget group -members | dsget user -samid -c >>c:\windows\temp\groupmembers.txt

If there are nested groups it might fail with the following error message:

The object class of the target does not match the one specified on the command line.

This error is removed by adding the -c variable as this continues despite the error.

Tags: , , , , , ,
Filed under Scripts/Reg | No Comments »