magnify
Home Active Directory Export All User Properties to Excel Kullanıcı Bilgilerini export etme
formats

Export All User Properties to Excel Kullanıcı Bilgilerini export etme

Aşağıdaki Script bu iş içindir ve test edilmiş başarılı bir şekilde çalışmaktadır. Ancak bu script çalışacak makinede excel yüklü olmalıdır.

VBScript
SET objRootDSE = GETOBJECT("LDAP://RootDSE")
strExportFile = "C:\temp\MyExport.xls" 

strRoot = objRootDSE.GET("DefaultNamingContext")
strfilter = "(&(objectCategory=Person)(objectClass=User))"
strAttributes = "sAMAccountName,userPrincipalName,givenName,sn," & _
                                "initials,displayName,physicalDeliveryOfficeName," & _
                                "telephoneNumber,mail,wWWHomePage,profilePath," & _
                                "scriptPath,homeDirectory,homeDrive,title,department," & _
                                "company,manager,homePhone,pager,mobile," & _
                                "facsimileTelephoneNumber,ipphone,info," & _
                                "streetAddress,postOfficeBox,l,st,postalCode,c"
strScope = "subtree"
SET cn = CREATEOBJECT("ADODB.Connection")
SET cmd = CREATEOBJECT("ADODB.Command")
cn.Provider = "ADsDSOObject"
cn.Open "Active Directory Provider"
cmd.ActiveConnection = cn

cmd.Properties("Page Size") = 1000

cmd.commandtext = "<LDAP://" & strRoot & ">;" & strFilter & ";" & _
                                   strAttributes & ";" & strScope

SET rs = cmd.EXECUTE

SET objExcel = CREATEOBJECT("Excel.Application")
SET objWB = objExcel.Workbooks.Add
SET objSheet = objWB.Worksheets(1)

FOR i = 0 To rs.Fields.Count - 1
                objSheet.Cells(1, i + 1).Value = rs.Fields(i).Name
                objSheet.Cells(1, i + 1).Font.Bold = TRUE
NEXT

objSheet.Range("A2").CopyFromRecordset(rs)
objWB.SaveAs(strExportFile)

rs.close
cn.close
SET objSheet = NOTHING
SET objWB =  NOTHING
objExcel.Quit()
SET objExcel = NOTHING

Wscript.echo "Script Finished..Please See " & strExportFile
 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
Export All User Properties to Excel Kullanıcı Bilgilerini export etme için yorumlar kapalı  comments 
© Hakan Uzuner
credit