I have tried this a couple of ways but still unable to save the output to a file here is what I have tried
$Groups = `
Get-DistributionGroup -ResultSize Unlimited -OrganizationalUnit "microsoft.com/finance" `
-ErrorAction SilentlyContinue
ForEach($Group in $Groups)
{
$group.DisplayName + ":"
Get-DistributionGroupMember $Group.DistinguishedName | %{"`t" + $_.Name} -append | outfile -path c:\temp\allcsv.csv
}
Open in new window
and I have also tried
$output = "c:\temp\gmembers.csv"
[array]$global:results = $null
$Groups = `
Get-DistributionGroup -ResultSize Unlimited -OrganizationalUnit "microsoft.com/finance" `
-ErrorAction SilentlyContinue
ForEach($Group in $Groups)
{
$group.DisplayName + ":"
Get-DistributionGroupMember $Group.DistinguishedName | %{"`t" + $_.Name}
}
$global:results | export-csv -path $output -nti
Open in new window