问题描述
我想找到一种方法(最好是VB脚本或PowerShell)来生成报告,该报告显示域中的所有用户帐户,并显示其所属的组。
I would like to find a way (VB Script or PowerShell preferably) of generating a report which displays all user accounts on the domain, and displays the groups of which they are a member.
我希望以以下格式将其导出到Excel电子表格:
I would like this to be exported to a Excel spreadsheet in the following format:
我一直在玩Quest Powershell Commands for AD和提出以下内容:
I have been playing around with Quest Powershell Commands for AD and came up with the following:
get-qaduser * -sizelimit 0 | select Name,MemberOf | export-csv report.csv
但是在输出文件中显示为:
However this displays in the output file as:
Username1 | System.String[]
Username2 | System.String[]
Username3 | System.String[]
其中 System.String []
Where
System.String[]
should be the group names.
我该怎么办?
推荐答案
尝试此操作,您需要加入组名:
Try this, you need to join the group names:
$memberOf = @{n='MemberOf';e={ ($_.MemberOf -replace '^CN=([^,]+).+$','$1') -join ';' }}
Get-QADUser -SizeLimit 0 | `
Select-Object Name,DN,SamAccountName,$memberOf | `
Export-Csv report.csv
这篇关于如何显示所有域用户他们的组成员身份(Active Directory)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!