PowerShell Logo Small

ConvertTo-Csv



This is the built-in help made by Microsoft for the command 'ConvertTo-Csv', in PowerShell version 5 - as retrieved from Windows version 'Microsoft Windows Server 2012 R2 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Converts objects into a series of comma-separated value (CSV) variable-length strings.

SYNTAX


ConvertTo-Csv [-InputObject] <PSObject> [[-Delimiter] [<Char>]] [-InformationAction {SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend}] [-InformationVariable
[<System.String>]] [-NoTypeInformation] [<CommonParameters>]
ConvertTo-Csv [-InputObject] <PSObject> [-InformationAction {SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend}] [-InformationVariable [<System.String>]]
[-NoTypeInformation] [-UseCulture] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The ConvertTo-CSV cmdlet returns a series of comma-separated (CSV) strings that represents the objects that you submit. You can then use the ConvertFrom-CSV cmdlet to
re-create objects from the CSV strings. The resulting objects are CSV versions of the original objects that consist of string representations of the property values and no
methods.


You can also use the T:Microsoft.PowerShell.Commands.Export-Csv and T:Microsoft.PowerShell.Commands.Import-Csv cmdlets to convert objects to CSV strings (and back).
Export-CSV is the same as ConvertTo-CSV, except that it saves the CSV strings in a file.


You can use the parameters of the ConvertTo-CSV cmdlet to specify a delimiter other than a comma or to direct ConvertTo-CSV to use the default delimiter for the current
culture.


For more information, see Export-CSV, and see the Notes section.



<

RELATED LINKS

Online Version: http://go.microsoft.com/fwlink/p/?linkid=293949
ConvertFrom-Csv
Export-Csv
Import-Csv

REMARKS

<

Examples


-------------------------- EXAMPLE 1 --------------------------

PS C:\>get-process powershell | convertto-csv
#TYPE System.Diagnostics.Process
"__NounName","Name","Handles","VM","WS","PM","NPM","Path","Company","CPU","FileVersion","ProductVersion","Description",
"Product","BasePriority","ExitCode","HasExited","ExitTime","Handle","HandleCount","Id","MachineName","MainWindowHandle"
,"MainWindowTitle","MainModule","MaxWorkingSet","MinWorkingSet","Modules","NonpagedSystemMemorySize","NonpagedSystemMem
orySize64","PagedMemorySize","PagedMemorySize64","PagedSystemMemorySize","PagedSystemMemorySize64","PeakPagedMemorySize
","PeakPagedMemorySize64","PeakWorkingSet","PeakWorkingSet64","PeakVirtualMemorySize","PeakVirtualMemorySize64","Priori
tyBoostEnabled","PriorityClass","PrivateMemorySize","PrivateMemorySize64","PrivilegedProcessorTime","ProcessName","Proc
essorAffinity","Responding","SessionId","StartInfo","StartTime","SynchronizingObject","Threads","TotalProcessorTime","U
serProcessorTime","VirtualMemorySize","VirtualMemorySize64","EnableRaisingEvents","StandardInput","StandardOutput","Sta
ndardError","WorkingSet","WorkingSet64","Site","Container"
"Process","powershell","216","597544960","60399616","63197184","21692","C:\WINDOWS\system32\WindowsPowerShell\v1.0\powe
rshell.exe","Microsoft Corporation","3.4788223","6.1.6587.1 (fbl_srv_powershell(nigels).070711-0102)","6.1.6587.1","Win
dows PowerShell","Microsoft® Windows® Operating System","8",,"False",,"860","216","5132",".","5636936","Windows PowerSh
ell 2.0 (04/17/2008 00:10:40)","System.Diagnostics.ProcessModule (powershell.exe)","1413120","204800","System.Diagnosti
cs.ProcessModuleCollection","21692","21692","63197184","63197184","320080","320080","63868928","63868928","60715008","6
0715008","598642688","598642688","True","Normal","63197184","63197184","00:00:00.2028013","powershell","15","True","1",
"System.Diagnostics.ProcessStartInfo","4/21/2008 3:49:19 PM",,"System.Diagnostics.ProcessThreadCollection","00:00:03.51
00225","00:00:03.3072212","597544960","597544960","False",,,,"60399616","60399616",,



This command converts a single process object to CSV format. The command uses the Get-Process cmdlet to get the PowerShell process on the local computer. It uses a pipeline
operator (|) to send the command to the ConvertTo-CSV cmdlet, which converts it to a series of comma-separated strings.










-------------------------- EXAMPLE 2 --------------------------

PS C:\>$date = get-date
PS C:\>convertto-csv -inputobject $date -delimiter ";" -notypeinformation



This example converts a date object to CSV format.

The first command uses the Get-Date cmdlet to get the current date. It saves it in the $date variable.

The second command uses the ConvertTo-CSV cmdlet to convert the DateTime object in the $date variable to CSV format. The command uses the InputObject parameter to specify
the object to be converted. It uses the Delimiter parameter to specify the delimiter that separates the object properties. It uses the NoTypeInformation parameter to
suppress the #TYPE string.










-------------------------- EXAMPLE 3 --------------------------

PS C:\>get-eventlog -log "windows powershell" | convertto-csv -useculture



This command converts the Windows PowerShell event log on the local computer to a series of CSV strings.

The command uses the Get-EventLog cmdlet to get the events in the Windows PowerShell log. A pipeline operator (|) sends the events to the ConvertTo-CSV cmdlet, which
converts the events to CSV format. The command uses the UseCulture parameter, which uses the list separator for the current culture as the delimiter.