Functions/Copy-PSTemplate.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
function Copy-PSTemplate {
    <#
      .SYNOPSIS
          List template files
      .DESCRIPTION
          List available template files
      .PARAMETER Name
          Name of template(s)
      .PARAMETER
          Name of template(s)
  #>
  
  [CmdletBinding()]
      Param(     
          [string]$Name,
          [string]$Destination
      )
      $TemplateFolder="$PSScriptRoot\..\Templates"
      Write-Verbose "Copy template(s) from $TemplateFolder"
  
      if ([string]::IsNullOrEmpty($Name)) {
          Get-ChildItem "$TemplateFolder" | Copy-Item -Destination $Destination
      } else {
          Get-ChildItem "$TemplateFolder" -Filter "$Name" | Copy-Item -Destination $Destination
      }
  }