从通配符组中获取广告组成员和属性,然后导出到csv

时间:2018-03-24 07:56:56

标签: powershell active-directory

我正在尝试从名称以XX开头的组中导出组成员及其属性,因此输出为

output

使用我编写的代码,我可以获得所有用户和属性,但我也想在每个成员面前导出该组

$Groups = Get-ADGroup -filter {name -like "Group*"} | Select-Object Name
foreach ($Group in $Groups)
    {
    $Members = Get-ADGroupMember -Identity $($Group.name) -Recursive | Select-Object name
    foreach ($Member in $Members )

        { Get-ADUser -Identity $($Member.name) -Properties * | Select-object * | export-csv 

        }
    }

先谢谢你们,伙计们。

1 个答案:

答案 0 :(得分:0)

将用户对象存储在变量中,将该组添加为该对象的新成员并将其传递给 INSERT INTO target_table (fields) SELECT (fields) FROM @tmp as tmp INNER JOIN dbo.buff AS bf ON tmp.id = bf.id

Export-CSV