Re: Local groups that user belongs to by Arvind-ACS
Arvind-ACS
Wed Aug 09 10:16:13 CDT 2006
Hi,
You can create a text or XLS file, using the following command
Set objFile = objFSO.CreateTextFile("C:\Grpmem.txt")
and then use the objfile.writeline property to write the values out if
you are creating a text file. If you want the report in an excel format
then you have to tweak with the cells.
here's what you can do.
Set objExcel = CreateObject("Excel.Application")
'Open the worksheet
objExcel.Workbooks.Open "C:\grpmem.xls"
i=1
j=1
cn = "<User Name>"
Set colGroups = GetObject("WinNT://.")
colGroups.Filter = Array("group")
For Each objGroup In colGroups
For Each objUser in objGroup.Members
objExcel.Cells(i,j) = "Test" 'or you can change this with
objUser.Name to automaticaly write the user name in sheet.
If objUser.name = "test" Then
i=i+1
objExcel.Cells(i,j) = objGroup.Name
End If
Next
j=j+1
i=1
Next
objExcel.Workbooks.Close
Set objExcel = nothing
Let me know if it works for you.
Leszek wrote:
> Hello!
>
> I need a script, that will list me all user and groups, that he belongs to.
> But in special way:
>
> user1
> group1
> group2
> group3
> user2
> group1
> group2
> etc
>
> I have this script, but i don't know how to change it.... :(
>
> Set colGroups = GetObject("WinNT://.")
> colGroups.Filter = Array("group")
> For Each objGroup In colGroups
> For Each objUser in objGroup.Members
> If objUser.name = "test" Then
> Wscript.Echo objGroup.Name
> End If
> Next
> Next
>
> Anyone help me?