更新时间:2023-12-02 23:44:22
创建一个新的自定义对象并将其添加到 Import-Csv
创建。
$ fileContent = Import-csv $ file -headerDate Description
$ newRow = New-Object PsObject -Property @ {Date ='Text4'; Description ='Text5'}
$ fileContent + = $ newRow
Trying to figure out how to add a row to a csv file with titles. I get the content using:
$fileContent = Import-csv $file -header "Date", "Description"
$File
returns
Date,Description
Text1,text2
text3,text4
How do I append a row with a new date and description. Sorry I am relatively new to powershell. thanks to anyone that can help
Create a new custom object and add it to the object array that Import-Csv
creates.
$fileContent = Import-csv $file -header "Date", "Description"
$newRow = New-Object PsObject -Property @{ Date = 'Text4' ; Description = 'Text5' }
$fileContent += $newRow