Skip to content

Instantly share code, notes, and snippets.

@RobsonAutomator
Last active January 12, 2017 11:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RobsonAutomator/4d04a9bff0ca29d21919eb1068d4d0d7 to your computer and use it in GitHub Desktop.
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)
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