0

I have a few custom objects which I am exporting all to the same csv so I use the -Append switch, however, I want it to overwrite the existing file with the same name, how can I do this?

(Get-Content filelocation) | set-content filelocation
Filelocation

At the end of my custom objects I use this code

$CSV | Export-Csv filelocation -NoTypeInformation -Append

Currently doing this exports it all to the same CSV every time I run the script, making it so I have to delete the Csv before running the script again.

How can I sort this?

1
  • 1
    replace -append with -force? Commented Mar 20, 2020 at 14:56

1 Answer 1

1

Using the -Force flag after you specify the FileLocation will make it overwrite.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.