i have to export all domain groups with their members to csv. So each group has to get their own csv. in this csv has to be all group members.
I think i know where the problem is: $group value is @{name=xyz} not xyz. Probably thats why ADGroupMember -Identity isnt matching.
$groups = (Get-ADGroup -filter {GroupScope -eq "DomainLocal"} |Select-Object name)
foreach ($group in $groups) {
Add-Content -Path ("C:\"+$group) -Value (Get-ADGroupMember -Identity $group)
}
edit: code solved below. i would need help with adding users to each csv file. dunno how to look for them.
You need to modify the first line like that