Create directory if it doesn't exist

Share your PowerShell scripts for Deployment Manager

Moderators: Mike Upton, justin.caldicott, csmith, chirayu, DavidSimner

Create directory if it doesn't exist

Postby jtucker@inflexxion.com » Mon Jan 13, 2014 1:59 pm

Code: Select all
function CreateDirIfItDoesNotExist
{
param([string]$folder)
   "Entering Powershell Library: CreateDirIfItDoesNotExist: Test for existence of " + $folder | Write-host
   if (Test-Path $folder)
   {
      $folder + " already exists, not disturbing it!" | Write-host
   }
   {
      $folder + " does not exist, creating it" | Write-host
      New-Item $folder -type directory -Force
   }
}
jtucker@inflexxion.com
 
Posts: 12
Joined: Thu Jun 27, 2013 10:23 pm
Location: Boston

Return to Deployment Manager PowerShell Scripts

Who is online

Users browsing this forum: No registered users and 1 guest