It looks like a bunch of the answers here don't account for file encoding.
I just ran into this problem, for various other reasons, but
echo $null > $file
$null > $file
both produce a UTF-16-LE file, while
New-Item $file -type file
produces a UTF-8 file.
For whatever reason fc > $file
and fc >> $file
, also seem to produce UTF-8 files.
Out-File $file -encoding utf8
gives you a UTF-8-BOM file, while
Out-File $file -encoding ascii
gives you a UTF-8 file. Other valid (but untested) encodings that Out-File supports are: [[-Encoding] {unknown | string | unicode | bigendianunicode | utf8 | utf7 | utf32 | ascii | default | oem}]. You can also pipe stuff to Out-File to give the file some text data to store, and also an -append flag. For example:
echo $null | Out-File .\stuff.txt -Encoding ascii -Append
this example does not update the timestamp for some reason, but this one does:
echo foo | Out-File .\stuff.txt -Encoding ascii -Append
Although it does have the side effect of appending "foo" to the end of the file.
If you are unsure about what encoding you have, I've found VS-Code has a nifty feature where at the bottom right hand corner it says what the encoding is. I think Notepad++ also has a similar feature.
touch
command out of it. :)