Avatar of techdrive
techdrive
Flag for United States of America asked on

powershell saving output to a file

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

Powershell

Avatar of undefined
Last Comment
techdrive

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
nashiooka

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
techdrive

ASKER
thanks it works
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23