We help IT Professionals succeed at work.

Using csvde.exe to export 2 security groups from Active Directory

eclipse-support
on
Medium Priority
673 Views
Last Modified: 2008-01-09
very very urgent!!

I need to export two security groups from our Active Directory, i have been informed that csvde.exe is the best way to do this but i cant figure out how to use it, ive managed to export every object in the domain but i only need to export the members of two groups.

how do i do this?

thanks for any help you can give.
Comment
Watch Question

Commented:
Hi,

If it's just for visualization purposes, here's a script I use, many thanks to Bradley Buskey. It generates a html document, and the results are pretty clear.

HTH
Cheers

'==========================================================================
' Title:   GroupMembers.vbs
' Date:    08/20/2004
' Author:  Bradley Buskey
' Version: 1.00
' Updated: 08/24/2004
' Purpose: List the members in a group on NT domain or Active Directory
' Require: Domain/AD, Group Name
' Returns: HTML file containing the members of the group.
'==========================================================================
Option Explicit

Dim objGroup, objUser, objExplorer, fileOutput, objMember, count
Dim strUserName, strScriptPath, strScriptName, strUserID, strScrPath
Dim strGrpName, strDirectory

count = 0

strDirectory = inputbox ("Domain/AD", "Enter the Domain or AD to search.","MYDOMAIN")
strGrpName = inputbox ("Group Name", "Enter Group name to list members.","Domain Users")
strScriptPath = Wscript.ScriptFullName
strScriptName = Wscript.ScriptName
strScrPath = Left(strScriptPath, Len(strScriptPath) - Len(strScriptName))

Set objGroup = Getobject("WinNT://" & strDirectory & "/" & strGrpName & ",group")
Set objExplorer = WScript.CreateObject("InternetExplorer.Application", "IE_")

With objExplorer
      .Navigate "about:Blank"
      .Toolbar = 1
      .StatusBar = 0
      .Width = 800
      .Height = 600
      .Left = 75
      .Top = 0
      .Visible = 1
End With

Set fileOutput = objExplorer.Document

fileOutput.Open
fileOutput.WriteLn "<html>"
fileOutput.WriteLn "      <head>"
fileOutput.WriteLn "            <title>Current Members In '" & strGrpName & "' Group</title>"
fileOutput.WriteLn "            <style type='text/css'>"
fileOutput.WriteLn "            <!--"
fileOutput.WriteLn "              .head {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; font-weight: bold; color:'#ffffff' }"
fileOutput.WriteLn "              .category {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 9px; font-weight: bold; color: #666699 }"
fileOutput.WriteLn "              .result {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 9px; color: #000000 }"
fileOutput.WriteLn "              .TableHeading {font-family: Tahoma; font-size: 0.8em; color: black; text-align: center }"
fileOutput.WriteLn "              .TableSubHeading {font-family: Tahoma; font-size: 0.7em; color: black; text-align: center }"
fileOutput.WriteLn "              .PageHeading {font-family: Tahoma; font-size: 1.2em; color: Blue }"
fileOutput.WriteLn "              .TableDetails {font-family: Tahoma; font-size: 0.7em; font-weight: normal; text-align : left; color : white }"
fileOutput.WriteLn "              .header {font-family: Verdana; font-size: 1.2em; color: #666699; font-weight: normal; text-align : left }"
fileOutput.WriteLn "              .link {cursor: hand; }"
fileOutput.WriteLn "              .Copyright {font-family: Times New Roman; font-zize: 6pt; color: #6487DC; font-size:8pt}"
fileOutput.WriteLn "              a {color: '#000066'; text-decoration:none }"
fileOutput.WriteLn "              a:hover {color: '#ff0000'; text-decoration:none }"
fileOutput.WriteLn "              div.page { page-break-before: always }"
fileOutput.WriteLn "              .errortext {color:red}"
fileOutput.WriteLn "              .hightext {color:blue}"
fileOutput.WriteLn "              .warntext {color:#FFFF00}"
fileOutput.WriteLn "            -->"
fileOutput.WriteLn "            </style>"
fileOutput.WriteLn "      </head>"
fileOutput.WriteLn "      <body bgcolor='#FFFFFF' text='#000000' link='#0000FF' vlink='000099' alink='#00FF00'>"
fileOutput.WriteLn "            <table border='0' cellpadding='0' cellspacing='0' align='center' style='border-collapse: collapse' bordercolor='#111111' width='100%' id='TDocumentation'>"
fileOutput.WriteLn "                  <tr>"
fileOutput.WriteLn "                        <td width='15' background='"& strScrPath & "images/coinsupg.gif' height='15'><img height='15' alt=none src='"& strScrPath & "images/space15_15.gif' width='15'></td>"
fileOutput.WriteLn "                        <td colspan='3' background='"& strScrPath & "images/sup.gif' height=15><img height='15' alt=none src='"& strScrPath & "images/space15_15.gif' width='15'></td>"
fileOutput.WriteLn "                        <td width='15' background='"& strScrPath & "images/coinsupd.gif' height='15'><img height='15' alt=none src='"& strScrPath & "images/space15_15.gif' width='15'></td>"
fileOutput.WriteLn "                  </tr>"
fileOutput.WriteLn "                  <tr>"
fileOutput.WriteLn "                        <td width='15' background='"& strScrPath & "images/g.gif'><img height='15' alt=none src='"& strScrPath & "images/space15_15.gif' width='15'></td>"
fileOutput.WriteLn "                        <td colspan='3' align=center width='100%' background='"& strScrPath & "images/fond.gif'><b> Current Members In '" & strGrpName & "' Group </b></td>"
fileOutput.WriteLn "                        <td width='15' background='"& strScrPath & "images/d.gif'><img height='15' alt=none src='"& strScrPath & "images/space15_15.gif' width='15'></td>"
fileOutput.WriteLn "                  </tr>"
fileOutput.WriteLn "                  <tr>"
fileOutput.WriteLn "                        <td width='15' background='"& strScrPath & "images/g.gif'><img height='15' alt=none src='"& strScrPath & "images/space15_15.gif' width='15'></td>"
fileOutput.WriteLn "                        <td colspan='3' width='100%' background='"& strScrPath & "images/fond.gif' bgcolor='#b6b6b6'><hr></td>"
fileOutput.WriteLn "                        <td width='15' background='"& strScrPath & "images/d.gif'><img height='15' alt=none src='"& strScrPath & "images/space15_15.gif' width='15'></td>"
fileOutput.WriteLn "                  </tr>"
For Each objMember in objGroup.Members
      strUserID = objMember.name
      Set objUser = GetObject("WinNT://" & strDirectory & "/" & strUserID)
      strUserName = objUser.FullName
      fileOutput.WriteLn "                  <tr>"
      fileOutput.WriteLn "                        <td width='15' background='"& strScrPath & "images/g.gif'><img height='15' alt=none src='"& strScrPath & "images/space15_15.gif' width='15'></td>"
      fileOutput.WriteLn "                        <td align='right' width='49%' background='"& strScrPath & "images/fond.gif' bgcolor='#b6b6b6'>" & strUserID & "</td>"
      fileOutput.WriteLn "                        <td align='center' width='2%' background='"& strScrPath & "images/fond.gif' bgcolor='#b6b6b6'>&nbsp;:&nbsp;</td>"
      fileOutput.WriteLn "                        <td align='left' width='49%' background='"& strScrPath & "images/fond.gif' bgcolor='#b6b6b6'>" & strUserName & "</td>"
      fileOutput.WriteLn "                        <td width='15' background='"& strScrPath & "images/d.gif'><img height='15' alt=none src='"& strScrPath & "images/space15_15.gif' width='15'></td>"
      fileOutput.WriteLn "                  </tr>"
      count = count + 1
Next
fileOutput.WriteLn "                  <tr>"
fileOutput.WriteLn "                        <td width='15' background='"& strScrPath & "images/g.gif'><img height='15' alt=none src='"& strScrPath & "images/space15_15.gif' width='15'></td>"
fileOutput.WriteLn "                        <td colspan='3' align=center width='100%' background='"& strScrPath & "images/fond.gif' bgcolor='#b6b6b6'><hr></td>"
fileOutput.WriteLn "                        <td width='15' background='"& strScrPath & "images/d.gif'><img height='15' alt=none src='"& strScrPath & "images/space15_15.gif' width='15'></td>"
fileOutput.WriteLn "                  </tr>"
fileOutput.WriteLn "                  <tr>"
fileOutput.WriteLn "                        <td width='15' background='"& strScrPath & "images/g.gif'><img height='15' alt=none src='"& strScrPath & "images/space15_15.gif' width='15'></td>"
fileOutput.WriteLn "                        <td colspan='3' align=center width='100%' background='"& strScrPath & "images/fond.gif' bgcolor='#b6b6b6'><b>There were <i>" & count & "</i> group members.</b></td>"
fileOutput.WriteLn "                        <td width='15' background='"& strScrPath & "images/d.gif'><img height='15' alt=none src='"& strScrPath & "images/space15_15.gif' width='15'></td>"
fileOutput.WriteLn "                  </tr>"
fileOutput.WriteLn "                  <tr>"
fileOutput.WriteLn "                        <td width='15' background='"& strScrPath & "images/coininfg.gif' height='15'><img height='15' alt=none src='"& strScrPath & "images/space15_15.gif' width='15'></td>"
fileOutput.WriteLn "                        <td colspan='3' background='"& strScrPath & "images/inf.gif' height='15'><img height='15' alt=none src='"& strScrPath & "images/space15_15.gif' width='15'></td>"
fileOutput.WriteLn "                        <td width='15' background='"& strScrPath & "images/coininfd.gif' height='15'><img height='15' alt=none src='"& strScrPath & "images/space15_15.gif' width='15'></td>"
fileOutput.WriteLn "                  </tr>"
fileOutput.WriteLn "            </table>"
fileOutput.WriteLn "            <p><h5 align='center'>Copyright© 2004, Bradley Buskey</h5></p>"
fileOutput.WriteLn "      </body>"
fileOutput.WriteLn "<html>"
fileOutput.close

WScript.Quit

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
you don't have to use csvde

From a command prompt:

dsquery group -name groupname | dsget group -members -expand


the only thing in that syntax you have to change is "groupname" change it to "engineering" or whatever the security group is called.

Do that for both and you are done...if you want it to do both at the same time create a small batch file and do:

dsquery group -name groupname1 | dsget group -members -expand > output.txt
dsquery group -name groupname2 | dsget group -members -expand >> output.txt

and run the batch file.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.