Hi Team,
I am trying to get Group members from SharePoint, I need to export to csv, I don`t understand why double quotes is sourended each value. Please see the code below.
foreach($line in $csv) {
$exportData = Get-PnPGroupMembers -Identity $line.Url | Select-Object -Property Title
$exportusers = foreach($user in $exportData){
[PSCustomObject]@{ "Group" =$line.Url "users" = $user.Title}
}
}$exportusers | Export-Csv -Path $OutputFile -NoTypeInformation
here is the output
"PatientGO Studies (ShP Group)" "Allen, Sarah"
But expecting like
PatientGO Studies (ShP Group) Allen, Sarah
also i have update PS object like below.
$GroupData.Add($(New-Object PSObject -Property ([ordered]@{"GroupName" = $line.Url;"User" = $user.Title })))
output in PS is fine, but in put file still it shows with double quotes.
help please ?
Mithilesh TataPosted Apr 2, 2024, 12:44 PM
It seems like you're encountering an issue with the Export-Csv cmdlet adding double quotes around each value in the CSV file. This behavior is normal for Export-Csv, as it encloses each value in double quotes to ensure proper CSV formatting.
If you want to export the data without double quotes around each value, you can use the Export-Csv cmdlet with the -NoTypeInformation parameter to suppress the type information from being included in the CSV file. Additionally, you can use the -Delimiter parameter to specify a different delimiter character, such as a comma or semicolon.
Here's how you can modify your code to export the data without double quotes around each value:
In this example, I've added the -Delimiter ";" parameter to specify that the CSV file should use a semicolon as the delimiter character. You can adjust the delimiter as needed for your requirements. Additionally, I've used the -Append parameter with Export-Csv to append the data to the CSV file for each iteration of the foreach loop.