Check if a Folder exists and create it if not

The following PowerShell code verifies if a specific single directory or even a whole directory path exists and creates it if not.

1
2
3
4
5
$myPath = "C:\temp\myPath"
 
if(!(Test-Path $myPath)){
    New-Item -ItemType Directory -Path $myPath
}

Leave a Reply

Your email address will not be published. Required fields are marked *