Search EggHeadCafe's Job Board
EggHeadCafe Silverlight WPF ASP.NET VB.NET C# Excel SQL Server SharePoint
search
.NET Framework GroupsView
.NET Distributed_Apps
.NET
.NET ADO.NET
.NET ASP.NET
.NET ASP.NET Security
.NET ASP.NET Webcontrols
.NET ASP.NET Web Services
.NET Clr
.NET Compact Framework
.NET Drawing
.NET Interop
.NET Performance
.NET Web Services
.NET Windows Forms
.NET Windows Forms Controls
.NET General
.NET Csharp
.NET Visual Basic
.NET Vc
.NET Security
.NET Xml
Vsnet Debugging
Xml
Xsl
Scripting Jscript
Scripting Visual Basicscript
Scripting Wsh
Smartphone Developer
Visual Basic Com
Visual Basic Controls
Visual Basic Crystal
Visual Basic Database Ado
Visual Basic Syntax
Visual Basic Winapi
Vc Atl
Vc Debugger
Vc Language
Vc Mfc
Vc Stl
Visio Developer Visual Basica
Windowsce Embedded Vc
Windows Powershell
Visual Basic Vista Compatibility
Deployment Server
.NET Micro Porting

Group SummariesView
.NET Framework
Access
BizTalk
Certifications
CRM
DDK
Exchange Server
FoxPro
French
French .NET
Games
German
German .NET
Graphic Design
IIS
Internet
ISA Server
Italian
Italian .NET
Maps
MCIS
Miscellaneous
Mobile Apps
Money
MSN
Networking
Office
Ops Mgr
Publisher
Security
SharePoint
Small Business
Spanish
Spanish .NET
SQL Server
Systems Management Server
Transaction Server
Virtual PC / Virtual Server
Visual Studio
Win32
Windows 2000
Windows 2003 Server
Windows 7
Windows Live
Windows Media
Windows Update
Windows Vista
Windows XP
 

View All Microsoft Scripting Visual Basicscript Posts  Ask A New Question 

Problem with DGSET GROUP report

Richard Mueller [MVP] posted on Thursday, July 17, 2008 11:14 AM

It may be possible to do this with dsquery and dsget, but I tried for some
time and failed. Some of my attempts failed if any members of the group were
users (objects of class other than computer). A bigger problem might be that
these commands are only available on W2k3 DC's (and above). I would use a
VBScript program similar to:
==========
Option Explicit
Dim objGroup, objMember, strName
Dim strExcelPath, objExcel, objSheet, intRow

' Spreadsheet file to be created.
strExcelPath = "c:\scripts\Computers.xls"

' Bind to Excel object.
Set objExcel = CreateObject("Excel.Application")

' Create a new workbook.
objExcel.Workbooks.Add

' Bind to worksheet.
Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)

' Bind to the group object.
Set objGroup =
GetObject("LDAP://cn=AdobeAcrobat9,ou=*,ou=Groups,ou=*,DC=*,DC=*")

' Enumerate direct members.
intRow = 1
For Each objMember In objGroup.Members
If (objMember.Class = "computer") Then
' Retrieve NetBIOS name of computer.
strName = objMember.sAMAccountName
' Strip off trailing "$"
strName = Left(strName, Len(strName) - 1)
objSheet.Cells(intRow, 1).Value = strName
objSheet.Cells(intRow, 2).Value = objMember.description
intRow = intRow + 1
End If
Next

objExcel.ActiveWorkbook.SaveAs strExcelPath
objExcel.ActiveWorkbook.Close
========
reply

 

First, you may be able to use Joe Richards' free adfind utility for

Richard Mueller [MVP] posted on Thursday, July 17, 2008 11:42 AM

First, you may be able to use Joe Richards' free adfind utility for this:

http://www.joeware.net/freetools/tools/adfind/index.htm

This still has the drawback that people that use it need the tool, but at
least it's one exe. PowerShell requires .NET framework, PowerShell, and the
cmdlets.

Next, I just noticed you used -expand to reveal nested group members. In
VBScript we can do the same thing with a recursive subroutine:
=======
Option Explicit
Dim objGroup
Dim strExcelPath, objExcel, objSheet, intRow

' Spreadsheet file to be created.
strExcelPath = "c:\scripts\Computers.xls"

' Bind to Excel object.
Set objExcel = CreateObject("Excel.Application")

' Create a new workbook.
objExcel.Workbooks.Add

' Bind to worksheet.
Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)

' Bind to the group object.
Set objGroup =
GetObject("LDAP://cn=AdobeAcrobat9,ou=*,ou=Groups,ou=*,DC=*,DC=*")

' Enumerate members.
intRow = 1
Call GetMembers(objGroup)

objExcel.ActiveWorkbook.SaveAs strExcelPath
objExcel.ActiveWorkbook.Close

Sub GetMembers(objParent)
' Recursive subroutine to enumerate nested group membership.
' objSheet and intRow must have global scope.
Dim objParent, strName

For Each objMember In objParent.Members
If (objMember.Class = "computer") Then
' Retrieve NetBIOS name of computer.
strName = objMember.sAMAccountName
' Strip off trailing "$"
strName = Left(strName, Len(strName) - 1)
objSheet.Cells(intRow, 1).Value = strName
objSheet.Cells(intRow, 2).Value = objMember.description
intRow = intRow + 1
End If
If (objMember.Class = "group") Then
Call GetMembers(objMember)
End If
Next
End Sub

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--
reply

Problem with DGSET GROUP report

rosevillec posted on Friday, July 18, 2008 10:49 PM

I made a simple batch file to get a list of machines belonging to
certain groups, save it to a file then open it in Excel.

See below:

dsget group "cn=AdobeAcrobat9,ou=*,ou=Groups,ou=*,DC=*,DC=*" -members -
expand | sort > "c:\documents and settings\%username%\desktop
\spreadsheetname.xls
start excel.exe "c:\documents and settings\%username%\desktop
\spreadsheetname.xls


It works but the output is ugly with it displaying a bunch of info
about the path that to the OU that I don't need to look at, and, at
the same time, there is a bit more info I want that I can't get it to
display.

It has the following problems.

1.  Excel fails to seperate the OU info into seperate cells despite
the info being seperated by commas. (I'd like to solve this comma
seperation or just not show this info).

2.  I need to get the "description" field of the computers, but when I
try to add "desc" to dsget it gives the description field of the
AdobeAcrobat9 group instead the description field of each of the
members of the group.

3.  I really don't need it to display all the OU info.  All I'd like
it do is save a list of the machine names that belong to the
AdobeAcrobat9 group in a format Excel can display elegantly and in
alphabetical order.  The description field of each of the member
computers should be displayed in the same row as the computer name.

How can this be done?
Can it be done with a simple bat file or does it have to be a vbs
script?
reply

This can be done extremely easily in powershell with Quest's ActiveDirectory

Kuma posted on Friday, July 18, 2008 10:49 PM

This can be done extremely easily in powershell with Quest's Active
Directory cmdlets.
(Get-QADGroup -SearchRoot "ou=*,ou=Groups,ou=*,DC=*,DC=*" -Name
export results to the csv file
\spreadsheetname.csv" -NoTypeInformation

Invoke-Item "c:\documents and settings\$env:username\desktop
\spreadsheetname.csv"

Thats by far the easiest way i can think of to do it. Hope its helpful.
reply

Problem with DGSET GROUP report

rosevillec posted on Friday, July 18, 2008 10:49 PM

I've never seen Quest cmdlets before and all the domain controllers
are Server 2003.  There is no Server 2008 or powershell available.
So, this new Quest software would need to be installed on on
everyone's machine that needs to use that method to create the report?
reply

Problem with DGSET GROUP report

rosevillec posted on Friday, July 18, 2008 10:49 PM

members -
I
e
e
hat
=3D*")

I saved it as a vbs file, tried it and it fails with a message:
reply

Problem with DGSET GROUP report

rosevillec posted on Friday, July 18, 2008 10:49 PM

.
-members -
n I
ike
me
ere
that
a
C=3D*")
on

Nevermind, I figured out how to declare the variables and it works.
It runs successfully and saves the info to a file.
However, it doesn't work using the %username% path to the desktop or
automatically launch the file my original batch file though.
How can I have launch automatically so the user doesn't have to go
hunt for the file and click on it?
reply

Problem with DGSET GROUP report

Kuma posted on Sunday, July 20, 2008 2:34 PM

...
*" -members -
to
te
hen I
like
some
pwere
be that
se a
,DC=3D*")
tion

Powershell can run on 2k3 XP 2k8 and Vista, it just doesn't come
installed by default. The quest active directory cmdlets are free to
download and can make working with AD much simpler. Each computer that
you would want to make the report on would need to have it installed
though.
reply