Powershell - Create CSV File



Cmdlet

New-Item cmdlet is used to create a csv file and Set-Content cmdlet to put content into it.

Step 1

In this example, we're creating a new csv file named test.csv

Type the following command in PowerShell ISE Console

New-Item D:\temp\test\test.csv -ItemType File

You can see the test.csv created in D:\temp\test directory.

Step 2

In this example, we're adding content to test.csv.

Type the following command in PowerShell ISE Console

Set-Content D:\temp\test\test.csv 'Mahesh,Suresh,Ramesh'

Step 3

In this example, we're reading content of test.csv.

Get-Content D:\temp\test\test.csv

Output

You can see following output in PowerShell console.

Mahesh,Suresh,Ramesh
powershell_files_io.htm
Advertisements