{"id":3608,"date":"2010-10-03T11:03:35","date_gmt":"2010-10-03T07:03:35","guid":{"rendered":"http:\/\/msbro.ru\/?p=3608"},"modified":"2010-10-03T11:03:35","modified_gmt":"2010-10-03T07:03:35","slug":"skript-ehksport-vsekh-polzovatelejj-domena-v-excel","status":"publish","type":"post","link":"https:\/\/msbro.ru\/index.php\/archives\/3608","title":{"rendered":"\u0421\u043a\u0440\u0438\u043f\u0442: \u044d\u043a\u0441\u043f\u043e\u0440\u0442 \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0434\u043e\u043c\u0435\u043d\u0430 \u0432 Excel"},"content":{"rendered":"<p><!--more--><\/p>\n<pre>Visual Basic\r\n\r\nSET objRootDSE = GETOBJECT(\"LDAP:\/\/RootDSE\")\r\nstrExportFile = \"C:\\temp\\MyExport.xls\" \r\n\r\nstrRoot = objRootDSE.GET(\"DefaultNamingContext\")\r\nstrfilter = \"(&amp;(objectCategory=Person)(objectClass=User))\"\r\nstrAttributes = \"sAMAccountName,userPrincipalName,givenName,sn,\" &amp; _\r\n                                \"initials,displayName,physicalDeliveryOfficeName,\" &amp; _\r\n                                \"telephoneNumber,mail,wWWHomePage,profilePath,\" &amp; _\r\n                                \"scriptPath,homeDirectory,homeDrive,title,department,\" &amp; _\r\n                                \"company,manager,homePhone,pager,mobile,\" &amp; _\r\n                                \"facsimileTelephoneNumber,ipphone,info,\" &amp; _\r\n                                \"streetAddress,postOfficeBox,l,st,postalCode,c\"\r\nstrScope = \"subtree\"\r\nSET cn = CREATEOBJECT(\"ADODB.Connection\")\r\nSET cmd = CREATEOBJECT(\"ADODB.Command\")\r\ncn.Provider = \"ADsDSOObject\"\r\ncn.Open \"Active Directory Provider\"\r\ncmd.ActiveConnection = cn\r\n\r\ncmd.Properties(\"Page Size\") = 1000\r\n\r\ncmd.commandtext = \";\" &amp; strFilter &amp; \";\" &amp; _\r\n                                   strAttributes &amp; \";\" &amp; strScope\r\n\r\nSET rs = cmd.EXECUTE\r\n\r\nSET objExcel = CREATEOBJECT(\"Excel.Application\")\r\nSET objWB = objExcel.Workbooks.Add\r\nSET objSheet = objWB.Worksheets(1)\r\n\r\nFOR i = 0 To rs.Fields.Count - 1\r\n                objSheet.Cells(1, i + 1).Value = rs.Fields(i).Name\r\n                objSheet.Cells(1, i + 1).Font.Bold = TRUE\r\nNEXT\r\n\r\nobjSheet.Range(\"A2\").CopyFromRecordset(rs)\r\nobjWB.SaveAs(strExportFile)\r\n\r\nrs.close\r\ncn.close\r\nSET objSheet = NOTHING\r\nSET objWB =  NOTHING\r\nobjExcel.Quit()\r\nSET objExcel = NOTHING\r\n\r\nWscript.echo \"Script Finished..Please See \" &amp; strExportFile<\/pre>\n<p><a href=\"http:\/\/gallery.technet.microsoft.com\/ScriptCenter\/ru-ru\/4d192f4d-2830-4a3e-9352-64a7e696a36e\" target=\"_blank\">\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[953],"class_list":["post-3608","post","type-post","status-publish","format-standard","hentry","category-scripts","tag-visual-basic"],"_links":{"self":[{"href":"https:\/\/msbro.ru\/index.php\/wp-json\/wp\/v2\/posts\/3608"}],"collection":[{"href":"https:\/\/msbro.ru\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/msbro.ru\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/msbro.ru\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/msbro.ru\/index.php\/wp-json\/wp\/v2\/comments?post=3608"}],"version-history":[{"count":0,"href":"https:\/\/msbro.ru\/index.php\/wp-json\/wp\/v2\/posts\/3608\/revisions"}],"wp:attachment":[{"href":"https:\/\/msbro.ru\/index.php\/wp-json\/wp\/v2\/media?parent=3608"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/msbro.ru\/index.php\/wp-json\/wp\/v2\/categories?post=3608"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/msbro.ru\/index.php\/wp-json\/wp\/v2\/tags?post=3608"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}<!-- WP Super Cache is installed but broken. The constant WPCACHEHOME must be set in the file wp-config.php and point at the WP Super Cache plugin directory. -->