There are different ways to create empty files.
>> This command creates EmptyFile1.txt
New-Item -ItemType File -Name EmptyFile1.txt
>> This command creates EmptyFilter2.txt
Add-Content -Path EmptyFile2.txt -Value ''
In the below screenshot, you can see. Before we ran the Add-Content command, the file did not exist.
But, after the command ran, the file was created.
>> We can use Clear-Content to remove contents of a file.
> New-Item -ItemType File -Name EmptyFile3.txt -Value "Some data"
> Clear-Content -Path .\EmptyFile3.txt
We create a file with some content, then we delete the contents of that file with Clear-Content command
>> We can force create a file, then deletes the contents of the file
> New-Item -ItemType File -Name EmptyFile4.txt -Value "Some data"
> New-Item -ItemType File -Name EmptyFile4.txt -Force
You can see in the below screenshot, we first create a file with some content.
Then we force create the same file with no content, this deletes the old content.