CmdLets/New-ItemWrapper.ps1
|
Function New-ItemWrapper { [CmdletBinding()] Param( [Parameter(Mandatory=$True)][String]$Path ) $Parent = Split-Path $Path -Parent If (!(Test-path $Parent)) { New-ItemWrapper -Path $Parent } if ($Path -like "*:*"){ $Drive = $Path.Substring(0,$Path.Indexof(":")) $Provider = (Get-PSDrive -Name $Drive).Provider.Name } elseif ($Path -like "\\*") { $Provider = "FileSystem" } Switch ($Provider) { "Registry" { New-Item $Path | Out-Null } "FileSystem" { New-Item $Path -ItemType Directory | Out-Null } Default { New-Item $Path | Out-Null } } } |