First, you may be able to use Joe Richards' free adfind utility for - Richard Mueller [MVP] |
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
-- |
 |
Problem with DGSET GROUP report - rosevillec |
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? |
 |
This can be done extremely easily in powershell with Quest's ActiveDirectory - Kuma |
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. |
 |
Problem with DGSET GROUP report - rosevillec |
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? |
 |
Problem with DGSET GROUP report - rosevillec |
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: |
 |
Problem with DGSET GROUP report - rosevillec |
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? |
 |
Problem with DGSET GROUP report - Kuma |
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. |
 |