Creating new file through Windows Powershell Creating new file through Windows Powershell powershell powershell

Creating new file through Windows Powershell

I'm guessing you're trying to create a text file?

New-Item c:\scripts\new_file.txt -type file

Where "C:\scripts\new_file.txt" is the fully qualified path including the file name and extension.

Taken from TechNet article

To create file using echo

echo some-text  > filename.txt


C:\>echo This is a sample text file > sample.txtC:\>type sample.txtThis is a sample text fileC:\>

To create file using fsutil

fsutil file createnew filename number_of_bytes


fsutil file createnew sample2.txt 2000File C:\sample2.txt is createdC:\data>dir01/23/2016  09:34 PM     2,000 sample2.txtC:\data>


Fsutil can be used only by administrators. For non-admin users it throws up below error.

c:\>fsutil file /?

The FSUTIL utility requires that you have administrative privileges. c:>

Hope this helps!

street smart (quick, dirty but works): (might change the file and add an invisible character which might cause the compiler to fail)

$null > file.txt$null > file.html

Textbook method:

New-Item -path <path to the destination file> -type file


New-Item -path "c:\" -type file -name "somefile.txt"


ni file.xt -type file

absence of -path parameter means it creates it in the current working directory