r0ca Asked: 2010-03-13 08:47:47 +0800 CST2010-03-13 08:47:47 +0800 CST 2010-03-13 08:47:47 +0800 CST 如何将 AD 安全列表导出到 Excel 772 如何将安全成员的列表从安全组导出到 Excel 工作表。我在网上找到了一些代码,但我需要一个 UI 或可以做到这一点的软件。 我对Powershell持开放态度...... 问候, D. active-directory export microsoft-excel 2 个回答 Voted Best Answer mfinni 2010-03-13T09:01:16+08:002010-03-13T09:01:16+08:00 CSVDE会按照您的要求进行操作。 Zypher 2010-03-13T09:07:15+08:002010-03-13T09:07:15+08:00 下面是我用来通过 powershell 获取用户信息的用户信息脚本的快速破解,并将其放入 excel 电子表格中: 请注意,我还没有测试过这些修改,他们需要做一些工作才能一次完成多个组 #Make ADSI Connection $Group = [ADSI]"LDAP://<domain>/<ldap_cn_of_group" #Setup our excel File $Excel = new-object -comobject Excel.Application $Workbook = $Excel.workbooks.add() $Worksheet = $Workbook.worksheets.item(1) # Setup a counter for our rows(Start at 2 0 wich is cell A2, the header stuff goes at 1,0 which is A1) $Row = 2 #Create File and Header information #sc -path ADUIout.txt -value "Group,Membership" $Worksheet.cells.item(1,1) = "Group" $Worksheet.cells.item(1,4) = "Group Membership" #$Excel.visible = $TRUE $membership = $null foreach ($member in $Group.member) { $Worksheet.cells.item($Row, 1) = "$Group" $Worksheet.cells.item($Row, 2) = "$member" $Row++ } $Workbook.saveas("H:\ADUI.xls") $Workbookl.save() $Excel.quit() 这是原始脚本,以防有人想看它,或者如果您想了解一些概念: #Active Directory User information script #Make ADSI Connection $AD_Top = [ADSI]"LDAP://<domain>/<base_LDAP_String>" #Setup our excel File $Excel = new-object -comobject Excel.Application $Workbook = $Excel.workbooks.add() $Worksheet = $Workbook.worksheets.item(1) # Setup a counter for our rows(Start at 2 0 wich is cell A2, the header stuff goes at 1,0 which is A1) $Row = 2 #Create File and Header information #sc -path ADUIout.txt -value "User Name,Container,Last Logon, Logon Count, Group membership" $Worksheet.cells.item(1,1) = "User Name" $Worksheet.cells.item(1,2) = "Container" $Worksheet.cells.item(1,3) = "Last Logon Count" $Worksheet.cells.item(1,4) = "Group Membership" #$Excel.visible = $TRUE #Create the Header foreach ($Container in $AD_Top.psBase.children) { if(($Container.psBase.properties.name -notmatch "Computers") -AND ($Container.psBase.properties.name -notmatch "Servers") ` -AND ($Container.psBase.properties.name -notmatch "Domain Controllers") ` -AND ($Container.psBase.properties.name -notmatch "EmailDistribution") ` -AND ($Container.psBase.properties.name -notmatch "Security Groups") ` -AND ($Container.psBase.properties.name -notmatch "Microsoft Exchange System Objects") ` -AND ($Container.psBase.properties.name -notmatch "System") ` -AND ($Container.psBase.properties.name -notmatch "ForeignSecurityPrincipals")) { $outputCont = $Container.psBase.properties.name foreach ($user in $Container.psBase.children) { $dirSearch = new-object directoryservices.directorysearcher($user) $LastLogon = [datetime]::fromfiletime(($DirSearch.findone().properties.lastlogon)[0]) $Username = $User.cn $LogonCount = $User.logoncount $membership = $null foreach ($group in $user.memberof) { $membership = $membership + $group.substring(3).Remove($group.substring(3).indexOf(",")) + "`n" } #$output = "$Username,$outputCont,$LastLogon,$logonCount,$membership" $Worksheet.cells.item($Row, 1) = "$Username" $Worksheet.cells.item($Row, 2) = "$outputCont" $Worksheet.cells.item($Row, 3) = $LastLogon $Worksheet.cells.item($Row, 4) = $membership #ac -path ADUIout.txt -value $output $Row++ } } } $Workbook.saveas("H:\ADUI.xls") $Workbookl.save() $Excel.quit()
CSVDE会按照您的要求进行操作。
下面是我用来通过 powershell 获取用户信息的用户信息脚本的快速破解,并将其放入 excel 电子表格中:
请注意,我还没有测试过这些修改,他们需要做一些工作才能一次完成多个组
这是原始脚本,以防有人想看它,或者如果您想了解一些概念: