将Get-ADGroupMember管道结果导入ADO RecordSet

时间:2018-04-18 13:32:28

标签: powershell active-directory ado recordset

正在寻找一种将Get-ADGroupMember查询的结果直接传递给ADO Recordset的方法。我的代码:

$group = "myADgroupName"
Get-ADGroupMember $group | select-object "name" | Export-Csv -Path C:\test\$group.csv -Encoding ascii -NoTypeInformation

将返回作为广告组myADgroupName成员的计算机对象和其他组的列表,并成功将其导出到csv文件。

但是我很难找到如何将查询结果捕获到某种容器中,我稍后可以在脚本中使用。

我试过了:

$rsMembers = new-Object -COMObject ADODB.Recordset
$rsMembers.open
Get-ADGroupMember $comp | select-object "name" | $rsMembers

..返回错误:

Expressions are only allowed as the first element of a pipeline

还有:

$rsMembers | Get-ADGroupMember $comp | select-object "name"

..返回错误:

Can't validate empty parameter

还有:

$rsMembers = Get-ADGroupMember $group | select-object "name"

......没有一项工作。搜索了高层和低层的互联网,但没有成功。任何帮助表示赞赏!

0 个答案:

没有答案