February 2019
Intermediate to advanced
626 pages
15h 51m
English
ConvertTo-Csv turns objects in PowerShell into comma-separated value (CSV) strings:
PS> Get-Process -Id $pid | Select-Object Name, Id, Path | ConvertTo-Csv"Name","Id","Path""powershell_ise","9956","C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell_ise.exe"
In the preceding example, Windows PowerShell will also include type data by default.
ConvertFrom-Csv turns CSV-formatted strings into objects:
"David,0123456789,28" | ConvertFrom-Csv -Header Name, Phone, Age
As ConvertFrom-Csv is specifically written to read CSV-formatted data, it will discard quotes surrounding strings but will allow fields to spread across lines and so on. Consider the following example:
'David,0123456789,28,"1 Some street, ...
Read now
Unlock full access