PowerShell New-Item vs mkdir: Create Folders and Files

When you need to powershell create folder mkdir, two options appear: the familiar mkdir shortcut and the versatile New-Item cmdlet. Most PowerShell users start with mkdir because it mirrors the command prompt, but New-Item handles directories, files, symbolic links, registry keys, and more in one consistent syntax. Knowing the difference — and when they are literally the same thing — makes your scripts both portable and powerful.
Quick Answer / TL;DR
In PowerShell, mkdir is an alias for New-Item -ItemType Directory. Use New-Item when you need file creation, symbolic links, or registry keys. Use mkdir for quick interactive folder creation.
mkdir vs New-Item -ItemType Directory
In PowerShell, mkdir is not the external command you know from CMD — it is a built-in function that calls New-Item -ItemType Directory under the hood. The result is identical. Both return a DirectoryInfo object representing the created folder. The key advantage of New-Item is that its syntax is consistent with creating files, links, and other item types, making scripts easier to understand at a glance.
# Both are equivalent for directory creation
mkdir C:\Projects\NewApp
New-Item -Path C:\Projects\NewApp -ItemType Directory
Create Nested Directories
Both mkdir and New-Item create intermediate parent directories automatically when the path does not exist. This is different from md in CMD, which requires the parent to exist first. You can create an entire deep hierarchy in one command without pre-checking each level.
# Creates all three levels at once — no error if parents don't exist
New-Item -Path C:\Projects\2024\Q1\Reports -ItemType Directory -Force
# Same with mkdir
mkdir C:\Projects\2024\Q1\Reports
Create a File with New-Item
This is where New-Item diverges from mkdir. Use -ItemType File to create an empty file. You can also supply initial content with -Value. This is useful for creating placeholder files, config stubs, or log files during script initialization.
# Create an empty file
New-Item -Path C:\Logs\app.log -ItemType File
# Create a file with initial content
New-Item -Path C:\Config\settings.ini -ItemType File -Value "[Settings]`nVersion=1.0"
Create Symbolic Links
Symbolic links require New-Item -ItemType SymbolicLink — there is no mkdir shortcut for this. On modern Windows 10/11, you can create symlinks without elevation if Developer Mode is enabled. Otherwise, run PowerShell as Administrator.
# Create a symbolic link — requires admin or Developer Mode
New-Item -Path C:\Projects\CurrentRelease -ItemType SymbolicLink -Target C:\Projects\v2.5
# Verify the link
Get-Item C:\Projects\CurrentRelease | Select-Object LinkType, Target
Combine with Test-Path for Safe Creation
Creating a directory that already exists with New-Item throws an error by default. Suppress it with -Force (safe for directories — it does not overwrite contents) or guard with Test-Path for explicit control. Test-Path returns $true or $false — a Boolean you can use directly in an if statement.
$path = 'C:\Logs\Archive'
if (-not (Test-Path -Path $path)) {
New-Item -Path $path -ItemType Directory | Out-Null
Write-Host "Created $path"
} else {
Write-Host "$path already exists"
}
Bulk Folder Creation from Array
When provisioning a standard directory structure, loop over an array instead of repeating New-Item calls. This pattern is clean and easy to extend by modifying the array.
$folders = @(
'C:\AppData\Logs',
'C:\AppData\Temp',
'C:\AppData\Config',
'C:\AppData\Archive'
)
$folders | ForEach-Object {
New-Item -Path $_ -ItemType Directory -Force | Out-Null
Write-Host "Ensured: $_"
}
Common Errors and Fixes
- mkdir in PS is an alias for New-Item — they are functionally identical. If you find documentation saying one is better than the other for creating folders, they are the same call. The only reason to prefer
New-Itemis consistency when the same script also creates files or links. - Symbolic link creation requires admin or Developer Mode. If you run
New-Item -ItemType SymbolicLinkand receive “You do not have sufficient privilege to perform this operation,” either launch PowerShell as Administrator or enable Developer Mode in Windows Settings under System > For Developers.
Related Cmdlets / See Also
Wrapping Up
For everyday folder creation, mkdir and New-Item -ItemType Directory are interchangeable. Reach for New-Item explicitly when your script also creates files, symbolic links, or registry keys — the consistent syntax keeps things readable. Always pair with -Force or a Test-Path guard to handle pre-existing paths gracefully.


