PowerShell command to check if a directory exists and if not, create it

I often have to look up this simple PowerShell command. The following command checks if a folder exists and if not, creates it. Works great.

if ((Test-Path -path C:\Temp\Folder\) -ne $True) { New-Item C:\Temp\Folder\ -type directory; }

Leave a Reply