Last active
January 12, 2017 11:41
-
-
Save RobsonAutomator/4d04a9bff0ca29d21919eb1068d4d0d7 to your computer and use it in GitHub Desktop.
Create-Item wrapper for New-Item (New-Item always create new item even item already exist)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Create-Item | |
{ | |
<# | |
.SYNOPSIS | |
Creates a new item only when an item not exsit. | |
#> | |
[cmdletbinding()] | |
Param( | |
[Parameter(Mandatory)] | |
$Path, | |
[Parameter(Mandatory)] | |
$ItemType | |
) | |
if( -not (Test-Path -Path $Path) ) | |
{ | |
Write-Verbose "Item create: $Path" | |
$layouts = New-Item -Path $Path -ItemType $ItemType | |
} | |
else | |
{ | |
Write-Verbose "Item already exist: $Path" | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment