Functions/Copy-SourceFileToTargetFile.ps1

<#
    .SYNOPSIS
    Copies source file to target file.
    .DESCRIPTION
    Copies source file to target file.
    .EXAMPLE
    Copy-SourceFileToTargetFile -SourceFilePath "Y:\P4\LastCheckedIn\dev\DevNL_1234.bak" -TargetFilePath "C:\MSSQL\BCK\DevNL_1234.bak" -SkipIfExists
    .PARAMETER SourceFilePath
    Path name of the source file
    .PARAMETER TargetFilePath
    Path name of the target file
    .PARAMETER SkipIfExists
    Determines if copy must be skipped if target file already exists.
#>


function Copy-SourceFileToTargetFile
{
    [cmdletbinding()]
    param
    (
        [parameter(Mandatory=$true)]
        [string] $SourceFilePath,
        [parameter(Mandatory=$true)]
        [string] $TargetFilePath,
        [switch] $SkipIfExists
    )
    PROCESS
    {       
        if ((Test-Path $TargetFilePath) -eq $true -and ($SkipIfExists) -eq $true) {
            
            write-host "Target file $TargetFilePath already exists. Copy action skipped."
        } else {
            
            Copy-Item $SourceFilePath $TargetFilePath -Force -Verbose
        }
    }
}

Export-ModuleMember -Function Copy-SourceFileToTargetFile