我试图从一个AD组中获取组成员列表,并将其导出到csv文件。我有一个问题,我得到一个错误Get-ADGroupMember : The size limit for this request was exceeded
,因为我的数据超过5k。我通过应用-Expand Member
和使用Get-ADGroup GroupName -Properties Member
解决了这个问题。数据被导出到csv,但是,我只想要3列。目前我正在获取组中的所有列。我尝试使用Get-ADUser -Property name, objectClass,distinguishedName
,但它仍然输出组中的所有列。有没有办法只得到这三列?
这就是我的代码到目前为止的样子:
$groupNames = @("GroupName1", "GroupName2", "GroupName3", "GroupName4")
For ($i=0; $i -lt $groupNames.Length; $i++) {
$currentGroup = $groupNames[$i]
$csvPath = “$currentGroup.csv”
Get-ADGroup $groupNames[$i] -Properties Member | Select-Object -Expand Member | Get-ADUser -Property name, objectClass,distinguishedName | Export-CSV -Path $csvPath -NoTypeInformation
}
字符串
1条答案
按热度按时间oyxsuwqo1#
在输出到Csv以过滤感兴趣的属性之前,您缺少一个到
Select-Object name, objectClass, distinguishedName
的管道。这里有一个更有效的方法来执行您要做的事情,而不是查询每个member
组,而是向Active Directory询问每个memberof
组的所有用户:字符串