我希望通过powershell导出Active Directory中的用户及其组,但由于某种原因,我似乎无法使管道工作,我现在使用的powershell脚本是
`
$groups = get-adgroup -filter *
foreach ($group in $groups) {
$naam = $group.name
$members = Get-ADGroupMember -identity $group
write-host “Group: $naam”
write-host “————————————-”
foreach ($member in $members) {
$memnaam = $member.samaccountname
write-host “$naammem”
}`
我就是想不通有什么建议吗?
`
$groups = get-adgroup -filter *
foreach ($group in $groups) {
$naam = $group.name
$members = Get-ADGroupMember -identity $group
write-host “Group: $naam”
write-host “————————————-”
foreach ($member in $members) {
$memnaam = $member.samaccountname
write-host “$naammem”
} | Export-CSV c:\FileName.csv`
1条答案
按热度按时间9rygscc11#
检查变量名中的拼写错误(你有一个变量名),检查你是否关闭了所有的括号和大括号。更好的是,不要在不需要的地方使用变量: