Private/Copy-uAItem.ps1

Function Copy-uAItem {
    PARAM(
        [Parameter(Mandatory = $True, Position = 0)]
        $Source,
        [Parameter(Mandatory = $True, Position = 1)]
        $Destination,
        [switch]$Recurse,
        [string[]]$Exclude
    )

    If (Test-Path $Source) {
        # If the destination is a file, extract the directory part
        if ([System.IO.Path]::HasExtension($Destination)) {
            $DestinationDirectory = Split-Path $Destination -Parent
        } else {
            $DestinationDirectory = $Destination
        }

        # If the destination directory doesn't exist, create it
        if (-not (Test-Path $DestinationDirectory)) {
            New-Item -ItemType Directory -Path $DestinationDirectory -Force | Out-Null
        }

        Write-Verbose "Copy '$Source' to '$Destination'" -Verbose

        $copyItemParams = @{
            Path = $Source
            Destination = $Destination
            Recurse = $Recurse
        }

        if ($Exclude) {
            $copyItemParams.Add("Exclude", $Exclude)
        }

        Copy-Item @copyItemParams
    }
    Else {
        Write-Warning "There is no file '$Source'"
    }
}
# SIG # Begin signature block
# MIIRVgYJKoZIhvcNAQcCoIIRRzCCEUMCAQExDzANBglghkgBZQMEAgEFADB5Bgor
# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCDMGiMJ/X6tnHVm
# dqVzx/qoDLUzedRdyYhfAbKHQH+5LqCCDW0wggZyMIIEWqADAgECAghkM1HTxzif
# CDANBgkqhkiG9w0BAQsFADB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMx
# EDAOBgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8G
# A1UEAwwoU1NMLmNvbSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IFJTQTAe
# Fw0xNjA2MjQyMDQ0MzBaFw0zMTA2MjQyMDQ0MzBaMHgxCzAJBgNVBAYTAlVTMQ4w
# DAYDVQQIDAVUZXhhczEQMA4GA1UEBwwHSG91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