Home » How to Export CSV File With No Quotes Around Values in PowerShell

How to Export CSV File With No Quotes Around Values in PowerShell

To export data to a CSV file without enclosing no quotes around values, you can use the ConvertTo-Csv file with the -NoTypeInformation parameter.

The following method shows how you can do it with syntax.

Method 1: Export CSV without enclosing quotes around the field

$data |  ConvertTo-Csv -NoTypeInformation | ForEach-Object { $_ -replace '"' } | Out-File -FilePath "output.csv" -Encoding utf8

This example will export a CSV file without enclosing quotes around each field.

The following example shows how you can use this method.

How to Export CSV Without Enclosing Quotes Around Field in PowerShell

The following PowerShell script shows how you can do it.

# specify the file path
$csvFilePath = "C:\temp\log\processData.csv"

# select name and ID 
$processList = Get-Process | Select-Object Name, ID

# Export to csv file without no quotes around each field
$processList | ConvertTo-Csv -NoTypeInformation | ForEach-Object { $_ -replace '"'} | Out-File -FilePath $csvFilePath -Encoding utf8

Output:

PowerShell export csv with no quotes
PowerShell export csv with no quotes

In this script, we define a variable $csvFilePath that contains the csv file path.

We then select the process name and ID using the Get-Process cmdlet and store them in the $processList variable.

The $processList data is piped to the ConvertTo-Csv cmdlet to export data to a CSV file. This command creates the objects and pipes them to the Foreach-Object cmdlet to iterate over each object and remove double quotes from each line of the CSV content.

We then use the Out-File cmdlet to export the CSV content to the CSV file named “processData.csv” with UTF-8 encoding.

After running this script, the PowerShell will export data to a CSV file without enclosing quotes around each field.

Conclusion

I hope the above article on how to export data to a csv file without enclosing no quotes in PowerShell is helpful to you.

You can find more topics about Active Directory tools and PowerShell basics on the ActiveDirectoryTools home page.