Menu & Search
Create New Files and Folders in PowerShell

Create New Files and Folders in PowerShell

This post is some quick notes on creating a new files and directories using PowerShell.

There’s 3 wee highlights:
# Create a New Directory
# Create a New (.txt) File
# Add Text to the New File

Create a New Directory

New-Item is the command.

Remember tab completion for everything we’re doing here.

New-Item -ItemType Directory -Name Test_Stuff

Create a New (.txt) File

New-Item -ItemType File -Name Test_File.txt

Same again as above, New-Item. This time swap the ItemType from Directory to File.

Add Content to the Txt File

MS Docs : Add-Content & Get-Content.

Add-Content .\Test_File.txt -Value 'Hi hi!... just a wee message here.'
Get-Content .\Test_File.txt