public/New-Directory.ps1
function New-Directory { [CmdletBinding()] param ( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$Path ) process{ $ErrorActionPreference = 'Stop' try { $PathExists = Test-Path -Path $Path -ErrorAction Stop if (!$PathExists) { New-Item -Path $Path -Type Directory -ErrorAction Stop -Verbose } else { Write-Warning -Message "$Path already exists." } # if } catch { throw "$($MyInvocation.MyCommand.Name): $_.Exception.Message" } # try catch } # process } # function |