Create files and folders with New-Item

The forgotten PowerShell way to touch files and mkdir directories — including hard links and junctions.

WindowsFilescreatepowershellLow risk
Run New-Item -Path <path> -ItemType File (or -ItemType Directory) to create a file or folder from PowerShell.

01Command

Command
$ New-Item -Path 'C:\Temp\notes.txt' -ItemType File ; New-Item -Path 'C:\Temp\logs' -ItemType Directory

02What it does

New-Item is PowerShell's all-purpose creator: File, Directory, and on Windows also SymbolicLink, Junction, and HardLink via -ItemType. It creates intermediate parent directories automatically, so a single New-Item can build a deep path. -Value seeds the file with content, and -Force replaces an existing file instead of erroring.

03Risk

RiskLow risk
RequirementsPowerShell
!Warning: New-Item -ItemType File on an existing file errors out unless you pass -Force, which truncates the file to empty — you lose its contents.

04Undo

Undo
$ Remove-Item 'C:\Temp\notes.txt'

05Sources

  • New-Item - PowerShell
    SS64 · technical · 2026-09-17
    Evidence: SS64 lists supported -ItemType values including File, Directory, SymbolicLink, Junction and HardLink.
  • New-Item | Microsoft Learn
    Microsoft · vendor-doc · 2026-09-17
    Evidence: Microsoft documents New-Item with -ItemType File/Directory/SymbolicLink/Junction/HardLink and -Force to replace an existing file.

Last verified: 2026-09-17 · Category: Files & Folders

06Related solutions