How to add rows to CSV file in PowerShell?
In PowerShell, we can use the Add-Content
cmdlet to add your values and between each value add comma.
I suggest to put your values in separate variable to less the complexity.
$fileSource = "D:\info\data.csv"
$name = "Mohammed"
$address = "MyAddress"
$phone = "0512345678"
# Add variables in the $newRow without space between them
$newRow = $name,$address,$phone
# Add row in the csv file
$newRow | Add-Content -Path $fileSource