noone
Wed Nov 22 15:35:57 CST 2006
Il giorno Thu, 9 Nov 2006 08:38:03 -0800, =?Utf-8?B?ZHVzdHk=?=
<dusty@discussions.microsoft.com> ha scritto:
>I am trying to create a spread sheet of user located in a particular security
>group. I can go to the properties of the security group and click members to
>see all users in this particular group. I need a list of those users in a
>spread sheet. Any help is appreciated.
There are plenty of these scripts. Asked regularly in this ng. Mine works fine but there
might be nicer ones in www.scriptinganswers.com
Set WshShell = WScript.CreateObject("WScript.Shell")
Dim strGruppo(100)
' Ottiene il nome del dominio
strDomain = WshShell.ExpandEnvironmentStrings("%USERDOMAIN%")
wshShell.popup "Inizio creazione dei profili", 1,"PROFILI PER UTENTE ",64
Set objDomain = GetObject("WinNT://" & strDomain)
objDomain.Filter = Array("group")
'EXCEL: crea oggetto, lo rende visibile, aggiunge un foglio di lavoro.
Dim oXL
Set oXL = WScript.CreateObject("Excel.Application")
oXL.Visible = TRUE
oXL.WorkBooks.Add
' Crea la lista dei gruppi da due in su,
' la memorizza in un array e la scrive in excel
oXL.Cells(1, 1).Value = "Estrazione del:" & Date
oXL.Cells(2, 1).Value = "USERID"
oXL.Cells(2, 2).Value = "COGNOME,NOME"
i=1
For Each objGroup In objDomain
i=i+1 'Inizia dalla colonna 2 a scrivere i nomi dei gruppi
strGruppo(i)= objGroup.Name
oXL.Cells(2, i+1).Value = strGruppo(i)
' oXL.Cells(1, i).Value = strGruppo(i)
next
intNumeroGruppi= i 'Qui memorizzo il numero dei gruppi che ho trovato
objDomain.Filter = Array("user")
Riga=3 'Gli utenti comincio a scriverli dalla riga 2 in poi.
for each objUser in objDomain
if objUser.Fullname="Amministratore Sicurezza" or objUser.Fullname="nobody" or
objUser.Fullname="sesidpls" or objUser.Fullname="System User" or objUser.Fullname="usdsmb"
or objUser.Fullname="yctsa01" then
else
oXl.cells(Riga,1).Value = objUser.Name 'Userid nella prima colonna
for each objGroup in objUser.groups 'Per ogni gruppo di appartenenza
dell'utente...
for i=2 to intNumeroGruppi
if objGroup.Name = strGruppo(i) then oXL.Cells(Riga, i+1).value="*"
' if objGroup.Name = strGruppo(i) then oXL.Cells(Riga, i).value="*"
next
next
oXl.cells(Riga,2).Value = objUser.FullName 'mette il nome completo nell'ultima
colonna
' oXl.cells(Riga,intNumeroGruppi+1).Value = objUser.FullName 'mette il nome completo
nell'ultima colonna
Riga=Riga+1
oXL.cells(Riga,1).SELECT
end if
'iF RIGA > 4 THEN EXIT FOR
next
oXL.Range(oXL.cells(2,3),oXL.cells(2,intNumeroGruppi+1)).Select
oXL.Selection.Orientation = 90
oXL.Selection.Columns.AutoFit
oXL.Selection.Rows.AutoFit
oXL.Columns("A:B").Select
oXL.Selection.Columns.AutoFit
oXL.Selection.Rows.AutoFit
oXL.Range("C3").Select
oXL.ActiveWindow.FreezePanes = True
' oXL.Range(oXL.cells(1,1),oXL.cells(1,intNumeroGruppi+1)).Select
'OXL.Columns("B:B").ColumnWidth = 21.11
OXL.Range("A1:B2").Select
OXL.Selection.Font.Bold = True
'oXL.Columns("A:B").Select
oXL.Range(oXL.cells(2,1),oXL.cells(RIGA,2)).Select
oXL.Selection.AutoFilter
oXL.Range("A1").Select
oXL.ActiveSheet.PageSetup.PrintTitleRows = "$1:$2"
oXL.ActiveSheet.PageSetup.PrintTitleColumns = "$A:$B"
oXL.ActiveSheet.PageSetup.PrintArea = ""
oXL.ActiveSheet.PageSetup.LeftHeader = ""
oXL.ActiveSheet.PageSetup.CenterHeader = ""
oXL.ActiveSheet.PageSetup.RightHeader = ""
oXL.ActiveSheet.PageSetup.LeftFooter = ""
oXL.ActiveSheet.PageSetup.CenterFooter = ""
oXL.ActiveSheet.PageSetup.RightFooter = ""
oXL.ActiveSheet.PageSetup.PrintHeadings = False
oXL.ActiveSheet.PageSetup.PrintGridlines = True
'XL.ActiveSheet.PageSetup.PrintComments = xlPrintNoComments
oXL.ActiveSheet.PageSetup.PrintQuality = 600
oXL.ActiveSheet.PageSetup.CenterHorizontally = False
oXL.ActiveSheet.PageSetup.CenterVertically = False
'XL.ActiveSheet.PageSetup.Orientation = xlLandscape
oXL.ActiveSheet.PageSetup.Draft = False
'XL.ActiveSheet.PageSetup.PaperSize = xlPaperA4
oXL.ActiveSheet.PageSetup.FirstPageNumber = xlAutomatic
'XL.ActiveSheet.PageSetup.Order = xlOverThenDown
oXL.ActiveSheet.PageSetup.BlackAndWhite = False
oXL.ActiveSheet.PageSetup.Zoom = 100
oXL.ActiveSheet.PageSetup.PrintErrors = xlPrintErrorsDisplayed
wshShell.popup "Creazione dei profili effettuata", 1,"PROFILI PER UTENTE ",64
--
Giovanni Cenati (Aosta, Italy)
Write to user "Reventlov" and domain at katamail com
http://digilander.libero.it/Cenati (Esempi e programmi in VbScript)
--