Tutorial by Examples

Given the following CSV-file String,DateTime,Integer First,2016-12-01T12:00:00,30 Second,2015-12-01T12:00:00,20 Third,2015-12-01T12:00:00,20 One can import the CSV rows in PowerShell objects using the Import-Csv command > $listOfRows = Import-Csv .\example.csv > $listOfRows String ...
By default, Import-CSV imports all values as strings, so to get DateTime- and integer-objects, we need to cast or parse them. Using Foreach-Object: > $listOfRows = Import-Csv .\example.csv > $listOfRows | ForEach-Object { #Cast properties $_.DateTime = [datetime]$_.DateTime $...

Page 1 of 1