Hi,
I'm using below code to clear .csv file leaving the headers. But when the code is run, I get the headers in the same cell when I open it in Excel. Please see below screen.
Code:
If($DateDifference -gt 20)
{
(Get-Content $CSVPath | Select-Object -First 1) | Out-File "C:\temp\result.csv"
}
Result: https://prnt.sc/13ecdpx
How can I remove only the rows and keep the headers intact?
Thanks in advance.