Converting the FileSystemObject's CreateTextFile Method

Definition: Creates a new text file.

CreateTextFile

The New-Item cmdlet can be used to create a new file. You simply need to specify the folder in which you want to create the file, the name of the new file, and the type of item you’re creating (in this case a file). This example creates a file named test.txt in the C:\Temp folder:

New-Item C:\temp -name test.txt -type file

If the file test.txt already exists this command will generate an error. However, you can force the file to be overwritten by including the -force parameter:

New-Item C:\temp -name test.txt -type file -force

See conversions of other FileSystemObject methods and properties.
Return to the VBScript to Windows PowerShell home page