Powershell - creating files and folders programmatically

by robotix1986 22. October 2009 12:24

To create a file programmatically we can use the below command: -

new-item -path c:\Test -name MyTestFile.txt -type "file" -value "This is a Test File with sample contents."

the above command creates a file "MyTestFile.txt" within the "C:\Test" directory with the given contents.

To create a folder, we can use the below command: -

new-item -path D:\MyAlreadyExistingFolder -name MyNewFolder -type directory

This command creates a folder named "MyNewFolder" within the "MyAlreadyExistingFolder" folder.

The essential thing to be noted in the above commands is the 'new-item' cmdlet. For more details and additional usage of this command visit this page.

Till my next post

Regards,
AlD

Tags:

Powered by BlogEngine.NET 1.5.0.7
Theme by Mads Kristensen

About robotix1986

Yet another software developer in the software industry writing some kewl code and exploring new technologies when not doing the routine work stuff.

RecentComments

Comment RSS
Software Blogs - BlogCatalog Blog Directory