private/Ensure-SkylineDirectory.ps1
Function Ensure-SkylineDirectory { <# .SYNOPSIS Ensure local directory given an arbitrary local path .DESCRIPTION Ensure local directory given an arbitrary local path .EXAMPLE Ensure-SkylineDirectory -Path "C:\Schemas\Documents.xml" .EXAMPLE Ensure-SkylineDirectory -Path .\Schemas\Documents.xml .PARAMETER Path Path to ensure #> [cmdletbinding()] param( [parameter(Mandatory = $True, ValueFromPipeline = $True)] [string]$Path ) Process { Write-Debug ( "Running $($MyInvocation.MyCommand).`n" + "PSBoundParameters:`n$($PSBoundParameters | Format-List | Out-String)") Try { $PathDirectory = $Path.Substring(0, $Path.LastIndexOf("\")) $Directory = New-Item $PathDirectory -ItemType Directory -Force return $Directory.FullName } Catch { Throw $_ } } } |