Menu & Search
Create Folder If Not Exists in PowerShell

Create Folder If Not Exists in PowerShell

A quick post to note down a script that’ll create a folder if it doesn’t already exist in PowerShell.

This script utilises Test-Path which helps determin whether a path exists.

# create folder if not exists
$path = "c:\temp\"
If(!(test-path $path))
{
    New-Item -ItemType Directory -Force -Path $path
}

Share

0 Comments