Transferetto.psm1

function Remove-EmptyValue {
    [alias('Remove-EmptyValues')]
    [CmdletBinding()]
    param([alias('Splat', 'IDictionary')][Parameter(Mandatory)][System.Collections.IDictionary] $Hashtable,
        [string[]] $ExcludeParameter,
        [switch] $Recursive,
        [int] $Rerun,
        [switch] $DoNotRemoveNull,
        [switch] $DoNotRemoveEmpty,
        [switch] $DoNotRemoveEmptyArray,
        [switch] $DoNotRemoveEmptyDictionary)
    foreach ($Key in [string[]] $Hashtable.Keys) { if ($Key -notin $ExcludeParameter) { if ($Recursive) { if ($Hashtable[$Key] -is [System.Collections.IDictionary]) { if ($Hashtable[$Key].Count -eq 0) { if (-not $DoNotRemoveEmptyDictionary) { $Hashtable.Remove($Key) } } else { Remove-EmptyValue -Hashtable $Hashtable[$Key] -Recursive:$Recursive } } else { if (-not $DoNotRemoveNull -and $null -eq $Hashtable[$Key]) { $Hashtable.Remove($Key) } elseif (-not $DoNotRemoveEmpty -and $Hashtable[$Key] -is [string] -and $Hashtable[$Key] -eq '') { $Hashtable.Remove($Key) } elseif (-not $DoNotRemoveEmptyArray -and $Hashtable[$Key] -is [System.Collections.IList] -and $Hashtable[$Key].Count -eq 0) { $Hashtable.Remove($Key) } } } else { if (-not $DoNotRemoveNull -and $null -eq $Hashtable[$Key]) { $Hashtable.Remove($Key) } elseif (-not $DoNotRemoveEmpty -and $Hashtable[$Key] -is [string] -and $Hashtable[$Key] -eq '') { $Hashtable.Remove($Key) } elseif (-not $DoNotRemoveEmptyArray -and $Hashtable[$Key] -is [System.Collections.IList] -and $Hashtable[$Key].Count -eq 0) { $Hashtable.Remove($Key) } } } }
    if ($Rerun) { for ($i = 0; $i -lt $Rerun; $i++) { Remove-EmptyValue -Hashtable $Hashtable -Recursive:$Recursive } }
}
function Add-PrivateFTPFile {
    [cmdletBinding()]
    param([Parameter(Mandatory)][FluentFTP.FtpClient] $Client,
        [string] $RemotePath,
        [string] $LocalPath,
        [FluentFTP.FtpRemoteExists] $RemoteExists = [FluentFTP.FtpRemoteExists]::Skip,
        [FluentFTP.FtpVerify] $VerifyOptions = [FluentFTP.FtpVerify]::None,
        [switch] $CreateRemoteDirectory)
    try {
        $Message = $Client.UploadFile($LocalPath, $RemotePath, $RemoteExists, $CreateRemoteDirectory.IsPresent, $VerifyOptions)
        if ($Message -eq 'success') { $State = $true } else { $State = $false }
        $Status = [PSCustomObject] @{Action = 'UploadFile'
            LocalPath                       = $LocalPath
            RemotePath                      = $RemotePath
            Status                          = $State
            Message                         = $Message
        }
    } catch {
        $Status = [PSCustomObject] @{Action = 'UploadFile'
            LocalPath                       = $LocalPath
            RemotePath                      = $RemotePath
            Status                          = $false
            Message                         = "Error: $($_.Exception.Message)"
        }
        if ($PSBoundParameters.ErrorAction -eq 'Stop') {
            Write-Error $_
            return
        } else { Write-Warning "Add-PrivateFTPFile - Error: $($_.Exception.Message)" }
    }
    $Status
}
function Add-PrivateFTPFiles {
    [cmdletBinding()]
    param([Parameter(Mandatory)][FluentFTP.FtpClient] $Client,
        [string] $RemotePath,
        [string[]] $LocalPath,
        [System.IO.FileInfo[]] $LocalFile,
        [FluentFTP.FtpRemoteExists] $RemoteExists = [FluentFTP.FtpRemoteExists]::Skip,
        [FluentFTP.FtpVerify] $VerifyOptions = [FluentFTP.FtpVerify]::None,
        [FluentFTP.FtpError] $ErrorHandling = [FluentFTP.FtpError]::None,
        [switch] $CreateRemoteDirectory)
    try {
        if ($LocalFile) { $Message = $Client.UploadFiles([System.IO.FileInfo[]] $LocalFile, $RemotePath, $RemoteExists, $CreateRemoteDirectory.IsPresent, $VerifyOptions, $ErrorHandling) } else { $Message = $Client.UploadFiles([string[]] $LocalPath, $RemotePath, $RemoteExists, $CreateRemoteDirectory.IsPresent, $VerifyOptions, $ErrorHandling) }
        if ($Message -gt 1) { $State = $true } else { $State = $false }
        $Status = [PSCustomObject] @{Action = 'UploadFile'
            LocalPath                       = $LocalPath
            RemotePath                      = $RemotePath
            Status                          = $State
            Message                         = $Message
        }
    } catch {
        $Status = [PSCustomObject] @{Action = 'UploadFile'
            LocalPath                       = $LocalPath
            RemotePath                      = $RemotePath
            Status                          = $false
            Message                         = "Error: $($_.Exception.Message)"
        }
        if ($PSBoundParameters.ErrorAction -eq 'Stop') {
            Write-Error $_
            return
        } else { Write-Warning "Add-PrivateFTPFiles - Error: $($_.Exception.Message)" }
    }
    $Status
}
function Get-PrivateFTPFile {
    [cmdletBinding()]
    param([Parameter(Mandatory)][FluentFTP.FtpClient] $Client,
        [string] $LocalPath,
        [FluentFTP.FtpListItem] $RemoteFile,
        [string] $RemotePath,
        [FluentFTP.FtpLocalExists] $LocalExists,
        [FluentFTP.FtpVerify[]] $VerifyOptions,
        [FluentFTP.FtpError] $FtpError)
    if ($RemoteFile) {
        if ($RemoteFile.Type -eq 'File') { $FileToDownload = $RemoteFile.FullName } else {
            if (-not $Suppress) {
                return [PSCustomObject] @{Action = 'DownloadFile'
                    Status                       = $false
                    LocalPath                    = $LocalPath
                    RemotePath                   = $RemoteFile.FullName
                    Message                      = "Receive-FTPFile - Given path $($RemoteFile.FullName) is $($RemoteFile.Type). Skipping."
                }
            } else {
                Write-Warning "Receive-FTPFile - Given path $($RemoteFile.FullName) is a directory. Skipping."
                return
            }
        }
    } else { $FileToDownload = $RemotePath }
    try {
        $Message = $Client.DownloadFile($LocalPath, $FileToDownload, $LocalExists, $VerifyOptions)
        if ($Message -eq 'success') { $State = $true } else { $State = $false }
        $Status = [PSCustomObject] @{Action = 'DownloadFile'
            Status                          = $State
            LocalPath                       = $LocalPath
            RemotePath                      = $FileToDownload
            Message                         = $Message
        }
    } catch {
        $Status = [PSCustomObject] @{Action = 'DownloadFile'
            Status                          = $false
            LocalPath                       = $LocalPath
            RemotePath                      = $FileToDownload
            Message                         = "Error: $($_.Exception.Message)"
        }
        if ($PSBoundParameters.ErrorAction -eq 'Stop') {
            Write-Error $_
            return
        } else { Write-Warning "Receive-FTPFile - Error: $($_.Exception.Message)" }
    }
    $Status
}
function Get-PrivateFTPFiles {
    [cmdletBinding()]
    param([Parameter(Mandatory)][FluentFTP.FtpClient] $Client,
        [string] $LocalPath,
        [FluentFTP.FtpListItem[]] $RemoteFile,
        [string[]] $RemotePath,
        [FluentFTP.FtpLocalExists] $LocalExists,
        [FluentFTP.FtpVerify[]] $VerifyOptions,
        [FluentFTP.FtpError] $FtpError)
    if ($RemoteFile) {
        $FileToDownload = foreach ($File in $RemoteFile) {
            if ($File.Type -eq 'File') { $File.FullName } else {
                if (-not $Suppress) {
                    [PSCustomObject] @{Action = 'DownloadFile'
                        Status                = $false
                        LocalPath             = $LocalPath
                        RemotePath            = $File.FullName
                        Message               = "Receive-FTPFile - Given path $($RemoteFile.FullName) is $($RemoteFile.Type). Skipping."
                    }
                } else { Write-Warning "Receive-FTPFile - Given path $($RemoteFile.FullName) is a directory. Skipping." }
            }
        }
    } else { $FileToDownload = $RemotePath }
    try {
        $Message = $Client.DownloadFiles($LocalPath, ([string[]] $FileToDownload), $LocalExists, $VerifyOptions, $FtpError)
        if ($Message -gt 0) { $State = $true } else { $State = $false }
        $Status = [PSCustomObject] @{Action = 'DownloadFile'
            Status                          = $State
            LocalPath                       = $LocalPath
            RemotePath                      = $FileToDownload
            Message                         = $Message
        }
    } catch {
        $Status = [PSCustomObject] @{Action = 'DownloadFile'
            Status                          = $false
            LocalPath                       = $LocalPath
            RemotePath                      = $FileToDownload
            Message                         = "Error: $($_.Exception.Message)"
        }
        if ($PSBoundParameters.ErrorAction -eq 'Stop') {
            Write-Error $_
            return
        } else { Write-Warning "Receive-FTPFile - Error: $($_.Exception.Message)" }
    }
    $Status
}
function Compare-FTPFile {
    [cmdletBinding()]
    param([Parameter(Mandatory)][FluentFTP.FtpClient] $Client,
        [Parameter(Mandatory)][string] $LocalPath,
        [Parameter(Mandatory)][string] $RemotePath,
        [FluentFTP.FtpCompareOption] $CompareOption = [FluentFTP.FtpCompareOption]::Auto)
    if ($Client -and $Client.IsConnected -and -not $Client.Error) { $Client.CompareFile($LocalPath, $RemotePath, $CompareOption) }
}
function Connect-FTP {
    [cmdletBinding(DefaultParameterSetName = 'Password')]
    param([Parameter(ParameterSetName = 'FtpProfile')]
        [FluentFTP.FtpProfile] $FtpProfile,
        [Parameter(ParameterSetName = 'ClearText')]
        [Parameter(ParameterSetName = 'Password')]
        [string] $Server,
        [Parameter(ParameterSetName = 'ClearText')]
        [string] $Username,
        [Parameter(ParameterSetName = 'ClearText')]
        [string] $Password,
        [Parameter(ParameterSetName = 'Password')]
        [pscredential] $Credential,
        [Parameter(ParameterSetName = 'ClearText')]
        [Parameter(ParameterSetName = 'Password')]
        [FluentFTP.FtpEncryptionMode[]] $EncryptionMode,
        [Parameter(ParameterSetName = 'ClearText')]
        [Parameter(ParameterSetName = 'Password')]
        [FluentFTP.FtpDataConnectionType] $DataConnectionType,
        [Parameter(ParameterSetName = 'ClearText')]
        [Parameter(ParameterSetName = 'Password')]
        [FluentFTP.FtpsBuffering] $SslBuffering,
        [Parameter(ParameterSetName = 'ClearText')]
        [Parameter(ParameterSetName = 'Password')]
        [switch] $DisableDataConnectionEncryption,
        [Parameter(ParameterSetName = 'ClearText')]
        [Parameter(ParameterSetName = 'Password')]
        [switch] $DisableValidateCertificateRevocation,
        [Parameter(ParameterSetName = 'ClearText')]
        [Parameter(ParameterSetName = 'Password')]
        [switch] $ValidateAnyCertificate,
        [Parameter(ParameterSetName = 'ClearText')]
        [Parameter(ParameterSetName = 'Password')]
        [int] $Port,
        [Parameter(ParameterSetName = 'ClearText')]
        [Parameter(ParameterSetName = 'Password')]
        [switch] $SendHost,
        [Parameter(ParameterSetName = 'ClearText')]
        [Parameter(ParameterSetName = 'Password')]
        [switch] $SocketKeepAlive,
        [Parameter(ParameterSetName = 'ClearText')]
        [Parameter(ParameterSetName = 'Password')]
        [switch] $AutoConnect)
    if ($FtpProfile) {
        $Client = [FluentFTP.FtpClient]::new()
        $Client.LoadProfile($FtpProfile)
    } else {
        $Client = [FluentFTP.FtpClient]::new($Server)
        if ($Username -and $Password) { $Client.Credentials = [System.Net.NetworkCredential]::new($Username, $Password) } elseif ($Credential) { $Client.Credentials = [System.Net.NetworkCredential]::new($Credential.Username, $Credential.Password) } else {}
    }
    if ($Port) { $Client.Port = $Port }
    if ($DataConnectionType) { $Client.DataConnectionType = $DataConnectionType }
    if ($DisableDataConnectionEncryption) { $Client.DataConnectionEncryption = $false }
    if ($EncryptionMode) { $Client.EncryptionMode = $EncryptionMode }
    if ($ValidateAnyCertificate) { $Client.ValidateAnyCertificate = $true }
    if ($DisableValidateCertificateRevocation) { $Client.ValidateCertificateRevocation = $false }
    if ($SendHost) { $Client.SendHost = $true }
    if ($SocketKeepAlive) { $Client.SocketKeepAlive = $true }
    if ($FtpsBuffering) { $Client.SslBuffering = $SslBuffering }
    try {
        if ($AutoConnect) {
            $TempFtpProfile = $Client.AutoConnect()
            if ($TempFtpProfile -and $Client.IsConnected) {
                Write-Verbose "Following options where used to autoconnect: "
                foreach ($Name in $TempFtpProfile.PSObject.Properties.Name) { Write-Verbose "[x] $Name -> $($TempFtpProfile.$Name)" }
            }
        } else { $Client.Connect() }
        $Client | Add-Member -Name 'Error' -Value $null -Force -MemberType NoteProperty
    } catch {
        $Client | Add-Member -Name 'Error' -Value $($_.Exception.Message) -Force -MemberType NoteProperty
        if ($PSBoundParameters.ErrorAction -eq 'Stop') {
            Write-Error $_
            return
        } else { Write-Warning "Connect-FTP - Error: $($_.Exception.Message)" }
    }
    $Client
}
function Connect-SFTP {
    [cmdletBinding(DefaultParameterSetName = 'Password')]
    param([Parameter(ParameterSetName = 'ClearText', Mandatory)]
        [Parameter(ParameterSetName = 'Password', Mandatory)]
        [Parameter(ParameterSetName = 'PrivateKey', Mandatory)]
        [string] $Server,
        [Parameter(ParameterSetName = 'ClearText', Mandatory)]
        [Parameter(ParameterSetName = 'PrivateKey', Mandatory)]
        [string] $Username,
        [Parameter(ParameterSetName = 'ClearText', Mandatory)]
        [string] $Password,
        [Parameter(ParameterSetName = 'Password', Mandatory)]
        [pscredential] $Credential,
        [Parameter(Mandatory, ParameterSetName = 'PrivateKey')]
        [string] $PrivateKey,
        [Parameter(ParameterSetName = 'ClearText')]
        [Parameter(ParameterSetName = 'Password')]
        [Parameter(ParameterSetName = 'PrivateKey')]
        [int] $Port)
    try {
        if ($Username -and $Password) { $SftpClient = [Renci.SshNet.SftpClient]::new($Server, $Username, $Password) } elseif ($Credential) { $SftpClient = [Renci.SshNet.SftpClient]::new($Server, $Credential.Username, $Credential.GetNetworkCredential().Password) } elseif ($PrivateKey) {
            if (Test-Path -LiteralPath $PrivateKey) {
                [string]$PrivateKey = Resolve-Path -LiteralPath $PrivateKey -ErrorAction Stop | Select-Object -ExpandProperty ProviderPath
                $SftpClient = [Renci.SshNet.SftpClient]::new($Server, $Username, [Renci.SshNet.PrivateKeyFile]$PrivateKey)
            } else {
                if ($PSBoundParameters.ErrorAction -eq 'Stop') {
                    throw "PrivateKey $PrivateKey doesn't exists."
                    return
                } else {
                    Write-Warning "Connect-SFTP - PrivateKey $PrivateKey doesn't exists."
                    return
                }
            }
        } else {
            throw 'Not implemented and unexepected.'
            return
        }
    } catch {
        if ($PSBoundParameters.ErrorAction -eq 'Stop') {
            Write-Error $_
            return
        } else { Write-Warning "Connect-SFTP - Error: $($_.Exception.Message)" }
    }
    if ($Port) { $SftpClient.Port = $Port }
    try {
        $SftpClient.Connect()
        $SftpClient | Add-Member -Name 'Error' -Value $null -Force -MemberType NoteProperty
    } catch {
        $SftpClient | Add-Member -Name 'Error' -Value $($_.Exception.Message) -Force -MemberType NoteProperty
        if ($PSBoundParameters.ErrorAction -eq 'Stop') {
            Write-Error $_
            return
        } else { Write-Warning "Connect-SFTP - Error: $($_.Exception.Message)" }
    }
    $SftpClient
}
function Connect-SSH {
    [cmdletBinding(DefaultParameterSetName = 'Password')]
    param([Parameter(Mandatory, ParameterSetName = 'ClearText')]
        [Parameter(Mandatory, ParameterSetName = 'Password')]
        [Parameter(Mandatory, ParameterSetName = 'PrivateKey')]
        [string] $Server,
        [Parameter(Mandatory, ParameterSetName = 'ClearText')]
        [Parameter(Mandatory, ParameterSetName = 'PrivateKey')]
        [string] $Username,
        [Parameter(Mandatory, ParameterSetName = 'ClearText')]
        [string] $Password,
        [Parameter(Mandatory, ParameterSetName = 'Password')]
        [pscredential] $Credential,
        [Parameter(Mandatory, ParameterSetName = 'PrivateKey')]
        [string] $PrivateKey,
        [Parameter(ParameterSetName = 'ClearText')]
        [Parameter(ParameterSetName = 'Password')]
        [Parameter(ParameterSetName = 'PrivateKey')]
        [int] $Port)
    if ($Username -and $Password) { $SshClient = [Renci.SshNet.SshClient]::new($Server, $Username, $Password) } elseif ($Credential) { $SshClient = [Renci.SshNet.SshClient]::new($Server, $Credential.Username, $Credential.GetNetworkCredential().Password) } elseif ($PrivateKey) {
        [string]$PrivateKey = Resolve-Path $PrivateKey | Select-Object -ExpandProperty ProviderPath
        $SshClient = [Renci.SshNet.SshClient]::new($Server, $Username, [Renci.SshNet.PrivateKeyFile]$PrivateKey)
    } else { throw 'Not implemented and unexpected.' }
    if ($Port) { $SshClient.Port = $Port }
    try {
        $SshClient.Connect()
        $SshClient | Add-Member -Name 'Error' -Value $null -Force -MemberType NoteProperty
    } catch {
        $SshClient | Add-Member -Name 'Error' -Value $($_.Exception.Message) -Force -MemberType NoteProperty
        if ($PSBoundParameters.ErrorAction -eq 'Stop') {
            Write-Error $_
            return
        } else { Write-Warning "Connect-SSH - Error: $($_.Exception.Message)" }
    }
    $SshClient
}
function Disconnect-FTP {
    [cmdletBinding()]
    param([FluentFTP.FtpClient] $Client)
    if ($Client -and $Client.IsConnected) {
        try { $Client.Disconnect() } catch {
            if ($PSBoundParameters.ErrorAction -eq 'Stop') {
                Write-Error $_
                return
            } else { Write-Warning "Disconnect-FTP - Error: $($_.Exception.Message)" }
        }
    }
}
function Disconnect-SFTP {
    [cmdletBinding()]
    param([Parameter(Mandatory)][Renci.SshNet.SftpClient] $SftpClient)
    if ($SftpClient -and $SftpClient.IsConnected) {
        try { $SftpClient.Disconnect() } catch {
            if ($PSBoundParameters.ErrorAction -eq 'Stop') {
                Write-Error $_
                return
            } else { Write-Warning "Disconnect-SFTP - Error: $($_.Exception.Message)" }
        }
    }
}
function Get-FTPChecksum {
    [cmdletBinding()]
    param([Parameter(Mandatory)][FluentFTP.FtpClient] $Client,
        [Parameter(Mandatory)][string] $RemotePath,
        [FluentFTP.FtpHashAlgorithm] $HashAlgorithm = [FluentFTP.FtpHashAlgorithm]::MD5)
    if ($Client -and $Client.IsConnected -and -not $Client.Error) { $Client.GetChecksum($RemotePath, $HashAlgorithm) }
}
function Get-FTPChmod {
    [cmdletBinding()]
    param([Parameter(Mandatory)][FluentFTP.FtpClient] $Client,
        [string] $RemotePath)
    if ($Client -and $Client.IsConnected -and -not $Client.Error) { $Client.GetChmod($RemotePath) }
}
function Get-FTPList {
    [cmdletBinding()]
    param([alias('FtpPath')][string] $Path,
        [FluentFTP.FtpListOption] $Options,
        [Parameter(Mandatory)][FluentFTP.FtpClient] $Client)
    if ($Client -and $Client.IsConnected -and -not $Client.Error) {
        try { if ($Path -and $Options) { $Client.GetListing($Path, $Options) } elseif ($Path) { $Client.GetListing($Path) } else { $Client.GetListing() } } catch {
            if ($PSBoundParameters.ErrorAction -eq 'Stop') {
                Write-Error $_
                return
            } else { Write-Warning "Get-FTPList - Error: $($_.Exception.Message)" }
        }
    } else { Write-Warning "Get-FTPList - Skipped (IsConnected $($Client.IsConnected) / Error: $($Client.Error))" }
}
function Get-SFTPList {
    [cmdletBinding()]
    param([alias('FtpPath')][string] $Path,
        [Parameter(Mandatory)][Renci.SshNet.SftpClient] $SftpClient)
    if ($SftpClient -and $SftpClient.IsConnected -and -not $SftpClient.Error) {
        try { if ($Path) { $SftpClient.ListDirectory($Path) } else { $SftpClient.ListDirectory('') } } catch {
            if ($PSBoundParameters.ErrorAction -eq 'Stop') {
                Write-Error $_
                return
            } else { Write-Warning "Get-SFTPList - Error: $($_.Exception.Message)" }
        }
    } else { Write-Warning "Get-SFTPList - Skipped (IsConnected $($SftpClient.IsConnected) / Error: $($SftpClient.Error))" }
}
function Move-FTPDirectory {
    [cmdletBinding()]
    param([Parameter(Mandatory)][FluentFTP.FtpClient] $Client,
        [Parameter(Mandatory)][string] $RemoteSource,
        [Parameter(Mandatory)][string] $RemoteDestination,
        [FluentFTP.FtpRemoteExists] $RemoteExists = [FluentFTP.FtpRemoteExists]::Skip)
    if ($Client -and $Client.IsConnected -and -not $Client.Error) { $Client.MoveDirectory($RemoteSource, $RemoteDestination, $RemoteExists) }
}
function Move-FTPFile {
    [cmdletBinding()]
    param([Parameter(Mandatory)][FluentFTP.FtpClient] $Client,
        [Parameter(Mandatory)][string] $RemoteSource,
        [Parameter(Mandatory)][string] $RemoteDestination,
        [FluentFTP.FtpRemoteExists] $RemoteExists = [FluentFTP.FtpRemoteExists]::Skip)
    if ($Client -and $Client.IsConnected -and -not $Client.Error) { $Client.MoveFile($RemoteSource, $RemoteDestination, $RemoteExists) }
}
function Receive-FTPDirectory {
    [alias('Get-FTPDirectory')]
    [cmdletBinding()]
    param([Parameter(Mandatory)][FluentFTP.FtpClient] $Client,
        [string] $LocalPath,
        [Parameter(Mandatory)][string] $RemotePath,
        [FluentFTP.FtpFolderSyncMode] $FolderSyncMode = [FluentFTP.FtpFolderSyncMode]::Update,
        [FluentFTP.FtpLocalExists] $LocalExists,
        [FluentFTP.FtpVerify] $VerifyOptions,
        [FluentFTP.Rules.FtpRule[]] $Rules)
    if ($Client -and $Client.IsConnected -and -not $Client.Error) { $Client.DownloadDirectory($LocalPath, $RemotePath, $FolderSyncMode) }
}
function Receive-FTPFile {
    [alias('Get-FTPFile')]
    [cmdletBinding(DefaultParameterSetName = 'Text')]
    param([Parameter(ParameterSetName = 'Text')]
        [Parameter(ParameterSetName = 'Native')]
        [Parameter(Mandatory)][FluentFTP.FtpClient] $Client,
        [Parameter(ParameterSetName = 'Native')]
        [FluentFTP.FtpListItem[]] $RemoteFile,
        [Parameter(ParameterSetName = 'Text')]
        [Parameter(ParameterSetName = 'Native')]
        [string[]] $RemotePath,
        [Parameter(ParameterSetName = 'Text')]
        [Parameter(ParameterSetName = 'Native')]
        [string] $LocalPath,
        [Parameter(ParameterSetName = 'Text')]
        [Parameter(ParameterSetName = 'Native')]
        [FluentFTP.FtpLocalExists] $LocalExists = [FluentFTP.FtpLocalExists]::Skip,
        [Parameter(ParameterSetName = 'Text')]
        [Parameter(ParameterSetName = 'Native')]
        [FluentFTP.FtpVerify[]] $VerifyOptions = [FluentFTP.FtpVerify]::None,
        [Parameter(ParameterSetName = 'Text')]
        [Parameter(ParameterSetName = 'Native')]
        [FluentFTP.FtpError] $FtpError = [FluentFTP.FtpError]::Stop,
        [Parameter(ParameterSetName = 'Text')]
        [Parameter(ParameterSetName = 'Native')]
        [switch] $Suppress)
    if ($Client -and $Client.IsConnected -and -not $Client.Error) {
        $Path = Get-Item -LiteralPath $LocalPath -ErrorAction SilentlyContinue
        if ($Path -is [System.IO.DirectoryInfo]) { Get-PrivateFTPFiles -Client $Client -LocalPath $LocalPath -RemoteFile $RemoteFile -RemotePath $RemotePath -LocalExists $LocalExists -VerifyOptions $VerifyOptions -FtpError $FtpError } else {
            if ($RemoteFile.Count -gt 1 -or $RemotePath.Count -gt 1) {
                Write-Warning "Receive-FTPFile - Multiple files detected, but $LocalPath is not a directory or directory doesn't exists. "
                if ($RemoteFile) { $FileToDownload = $RemoteFile.FullName } else { $FileToDownload = $RemotePath }
                $Status = [PSCustomObject] @{Action = 'DownloadFile'
                    Status                          = $false
                    LocalPath                       = $LocalPath
                    RemotePath                      = $FileToDownload
                    Message                         = "Multiple files detected, but $LocalPath is not a directory or directory doesn't exists."
                }
            } else {
                $Splat = @{Client = $Client
                    LocalExists   = $LocalExists
                    VerifyOptions = $VerifyOptions
                    FtpError      = $FtpError
                    LocalPath     = $LocalPath
                }
                if ($RemoteFile) { $Splat.RemoteFile = $RemoteFile[0] } else { $Splat.RemotePath = $RemotePath[0] }
                Get-PrivateFTPFile @Splat
            }
        }
    } else {
        $Status = [PSCustomObject] @{Action = 'DownloadFile'
            Status                          = $false
            LocalPath                       = $LocalPath
            RemotePath                      = $FileToDownload
            Message                         = "Not connected."
        }
    }
    if (-not $Suppress) { $Status }
}
function Receive-SFTPFile {
    [alias('Get-SFTPFile')]
    [cmdletBinding()]
    param([Parameter(Mandatory)][Renci.SshNet.SftpClient] $SftpClient,
        [string] $RemotePath,
        [string] $LocalPath)
    if ($SftpClient -and $SftpClient.IsConnected) {
        try {
            $FileStream = [System.IO.FileStream]::new($LocalPath, [System.IO.FileMode]::OpenOrCreate)
            $SftpClient.DownloadFile($RemotePath, $FileStream)
            $Status = [PSCustomObject] @{Action = 'DownloadFile'
                Status                          = $true
                LocalPath                       = $LocalPath
                RemotePath                      = $RemotePath
                Message                         = ""
            }
        } catch {
            $Status = [PSCustomObject] @{Action = 'DownloadFile'
                Status                          = $false
                LocalPath                       = $LocalPath
                RemotePath                      = $RemotePath
                Message                         = "Error: $($_.Exception.Message)"
            }
            if ($PSBoundParameters.ErrorAction -eq 'Stop') {
                Write-Error $_
                return
            } else { Write-Warning "Receive-SFTPFile - Error: $($_.Exception.Message)" }
        } finally {
            $FileStream.Close()
            if ($Status.Status -eq $false) { Remove-Item -LiteralPath $LocalPath }
        }
        $Status
    }
}
function Remove-FTPDirectory {
    [cmdletBinding()]
    param([Parameter(Mandatory)][FluentFTP.FtpClient] $Client,
        [Parameter(Mandatory)][string] $RemotePath,
        [FluentFTP.FtpListOption] $FtpListOption)
    if ($Client -and $Client.IsConnected -and -not $Client.Error) { if (-not $FtpListOption) { $Client.DeleteDirectory($RemotePath) } else { $Client.DeleteDirectory($RemotePath, $FtpListOption) } }
}
function Remove-FTPFile {
    [cmdletBinding()]
    param([Parameter(Mandatory)][FluentFTP.FtpClient] $Client,
        [Parameter(Mandatory)][string] $RemotePath)
    if ($Client -and $Client.IsConnected -and -not $Client.Error) { $Client.DeleteFile($RemotePath) }
}
function Remove-SFTPFile {
    [cmdletBinding()]
    param([Parameter(Mandatory)][Renci.SshNet.SftpClient] $SftpClient,
        [string] $RemotePath,
        [switch] $Suppress)
    if ($SftpClient -and $SftpClient.IsConnected) {
        try {
            $SftpClient.DeleteFile($RemotePath)
            $Status = [PSCustomObject] @{Action = 'RemoveFile'
                Status                          = $true
                Message                         = ""
            }
        } catch {
            $Status = [PSCustomObject] @{Action = 'RemoveFile'
                Status                          = $false
                Message                         = "Error $($_.Exception.Message)"
            }
            if ($PSBoundParameters.ErrorAction -eq 'Stop') {
                Write-Error $_
                return
            } else { Write-Warning "Remove-SFTPFile - Error: $($_.Exception.Message)" }
        }
        if (-not $Suppress) { $Status }
    }
}
function Rename-FTPFile {
    [cmdletBinding()]
    param([Parameter(Mandatory)][FluentFTP.FtpClient] $Client,
        [Parameter(Mandatory)][string] $Path,
        [Parameter(Mandatory)][string] $DestinationPath)
    if ($Client -and $Client.IsConnected -and -not $Client.Error) { $Client.Rename($Path, $DestinationPath) }
}
function Rename-SFTPFile {
    [cmdletBinding()]
    param([Parameter(Mandatory)][Renci.SshNet.SftpClient] $SftpClient,
        [string] $RemotePath,
        [switch] $Suppress)
    if ($SftpClient -and $SftpClient.IsConnected) {
        try {
            $SftpClient.RenameFile($RemotePath)
            $Status = [PSCustomObject] @{Action = 'RenameFile'
                LocalPath                       = ''
                RemotePath                      = $RemotePath
                Status                          = $true
                Message                         = ""
            }
        } catch {
            $Status = [PSCustomObject] @{Action = 'RenameFile'
                Status                          = $false
                LocalPath                       = ''
                RemotePath                      = $RemotePath
                Message                         = "Error $($_.Exception.Message)"
            }
            if ($PSBoundParameters.ErrorAction -eq 'Stop') {
                Write-Error $_
                return
            } else { Write-Warning "Rename-SFTPFile - Error: $($_.Exception.Message)" }
        }
        if (-not $Suppress) { $Status }
    }
}
function Request-FTPConfiguration {
    <#
    .SYNOPSIS
    Short description
 
    .DESCRIPTION
    Automatically discover working FTP connection settings and return those connection profiles. This method will try every possible connection type combination in a loop until it finds a working combination, and it will return the first found combination or all found combinations. The connection types are tried in this order of preference.
 
    Auto connection attempts to find working connection settings in this order of preference:
 
    Protocol Preference:
    1. None - Let the OS decide which TLS/SSL version to use
    2. Tls12 - TLS 1.2 (TLS 1.3 is not yet stable in .NET Framework)
    3. Tls11 - TLS 1.1
    4. Tls - TLS 1.0
    5. Ssl3 - SSL 3.0 (obsolete, need to use TLS instead)
    6. Ssl2 - SSL 2.0 (obsolete, need to use TLS instead)
    7. Default - Undefined/weird behaviour
 
    Data Connection Type Preference:
 
    1. PASV - We prefer passive as its the most reliable
    2. EPSV - Enhanced passive is not as well supported on servers
    3. PORT - PORT is an older connection type
    4. EPRT - Enhanced PORT is not as well supported on servers
    5. PASVEX
 
    Encoding Type Preference:
 
    1. UTF8 - We prefer Unicode encoding as there will be no issues with file and folder names
    2. ASCII - ASCII/ANSI is a fallback used for older servers
 
    .PARAMETER Server
    Server Name or IP Address to Connect
 
    .PARAMETER Username
    UserName for FTP Connection
 
    .PARAMETER Password
    Password for FTP Connection (cleartext)
 
    .PARAMETER Credential
    UserName and Password in form of Credentials
 
    .PARAMETER FirstOnly
    Returns first working profile
 
    .EXAMPLE
    # Login via UserName/Password
    $ProfileFtp1 = Request-FTPConfiguration -Server 'test.rebex.net' -Verbose -Username 'demo' -Password 'password'
    $ProfileFtp1 | Format-Table
 
    .EXAMPLE
    # Anonymous login
    $ProfileFtp2 = Request-FTPConfiguration -Server 'speedtest.tele2.net' -Verbose
    $ProfileFtp2 | Format-Table
 
    .NOTES
    General notes
    #>

    [cmdletBinding(DefaultParameterSetName = 'Password')]
    param([Parameter(ParameterSetName = 'ClearText')]
        [Parameter(ParameterSetName = 'Password')]
        [string] $Server,
        [Parameter(ParameterSetName = 'ClearText')]
        [string] $Username,
        [Parameter(ParameterSetName = 'ClearText')]
        [string] $Password,
        [Parameter(ParameterSetName = 'Password')]
        [pscredential] $Credential,
        [Parameter(ParameterSetName = 'ClearText')]
        [Parameter(ParameterSetName = 'Password')]
        [switch] $FirstOnly)
    $Client = [FluentFTP.FtpClient]::new($Server)
    if ($Username -and $Password) { $Client.Credentials = [System.Net.NetworkCredential]::new($Username, $Password) } elseif ($Credential) { $Client.Credentials = [System.Net.NetworkCredential]::new($Credential.Username, $Credential.Password) } else {}
    try { $Client.AutoDetect($FirstOnly.IsPresent) } catch {
        $Client | Add-Member -Name 'Error' -Value $($_.Exception.Message) -Force -MemberType NoteProperty
        if ($PSBoundParameters.ErrorAction -eq 'Stop') {
            Write-Error $_
            return
        } else { Write-Warning "Request-FTPConfiguration - Error: $($_.Exception.Message)" }
    }
}
function Send-FTPDirectory {
    [alias('Add-FTPDirectory')]
    [cmdletBinding()]
    param([Parameter(Mandatory)][FluentFTP.FtpClient] $Client,
        [string] $LocalPath,
        [Parameter(Mandatory)][string] $RemotePath,
        [FluentFTP.FtpFolderSyncMode] $FolderSyncMode = [FluentFTP.FtpFolderSyncMode]::Update,
        [FluentFTP.FtpRemoteExists] $RemoteExists,
        [FluentFTP.FtpVerify] $VerifyOptions,
        [FluentFTP.Rules.FtpRule[]] $Rules)
    if ($Client -and $Client.IsConnected -and -not $Client.Error) { $Client.UploadDirectory($LocalPath, $RemotePath, $FolderSyncMode) }
}
function Send-FTPFile {
    [alias('Add-FTPFile')]
    [cmdletBinding()]
    param([Parameter(Mandatory)][FluentFTP.FtpClient] $Client,
        [string] $RemotePath,
        [System.IO.FileInfo[]] $LocalFile,
        [string[]] $LocalPath,
        [FluentFTP.FtpRemoteExists] $RemoteExists = [FluentFTP.FtpRemoteExists]::Skip,
        [FluentFTP.FtpVerify] $VerifyOptions = [FluentFTP.FtpVerify]::None,
        [FluentFTP.FtpError] $ErrorHandling = [FluentFTP.FtpError]::None,
        [switch] $CreateRemoteDirectory)
    if ($Client -and $Client.IsConnected -and -not $Client.Error) {
        if ($LocalPath.Count -gt 1 -or $LocalFile.Count -gt 1) {
            $Splat = @{Client         = $Client
                RemoteExists          = $RemoteExists
                VerifyOptions         = $VerifyOptions
                LocalPath             = $LocalPath
                LocalFile             = $LocalFile
                RemotePath            = $RemotePath
                CreateRemoteDirectory = $CreateRemoteDirectory.IsPresent
                ErrorHandling         = $ErrorHandling
            }
            Remove-EmptyValue -Hashtable $Splat
            $Status = Add-PrivateFTPFiles @Splat
            $Status
        } else {
            foreach ($Path in $LocalPath) {
                $Splat = @{Client         = $Client
                    RemoteExists          = $RemoteExists
                    VerifyOptions         = $VerifyOptions
                    LocalPath             = $Path
                    RemotePath            = $RemotePath
                    CreateRemoteDirectory = $CreateRemoteDirectory.IsPresent
                }
                $Status = Add-PrivateFTPFile @Splat
                $Status
            }
        }
    }
}
function Send-SFTPFile {
    [alias('Add-SFTPFile')]
    [cmdletBinding()]
    param([Parameter(Mandatory)][Renci.SshNet.SftpClient] $SftpClient,
        [string] $RemotePath,
        [string] $LocalPath,
        [switch] $AllowOverride)
    if ($SftpClient -and $SftpClient.IsConnected) {
        if (Test-Path -LiteralPath $LocalPath) {
            try {
                $FileStream = [System.IO.FileStream]::new($LocalPath, [System.IO.FileMode]::OpenOrCreate)
                $SftpClient.UploadFile($FileStream, $RemotePath, $AllowOverride)
                $Status = [PSCustomObject] @{Action = 'UploadFile'
                    Status                          = $true
                    LocalPath                       = $LocalPath
                    RemotePath                      = $RemotePath
                    Message                         = ""
                }
            } catch {
                $Status = [PSCustomObject] @{Action = 'UploadFile'
                    Status                          = $false
                    LocalPath                       = $LocalPath
                    RemotePath                      = $RemotePath
                    Message                         = "Error: $($_.Exception.Message)"
                }
                if ($PSBoundParameters.ErrorAction -eq 'Stop') {
                    Write-Error $_
                    return
                } else { Write-Warning "Send-SFTPFile - Error: $($_.Exception.Message)" }
            } finally { $FileStream.Close() }
        } else {
            Write-Warning "Send-SFTPFile - File $LocalPath doesn't exists."
            $Status = [PSCustomObject] @{Action = 'UploadFile'
                Status                          = $false
                LocalPath                       = $LocalPath
                RemotePath                      = $RemotePath
                Message                         = "LocalPath doesn't exists $LocalPath"
            }
        }
        $Status
    }
}
function Send-SSHCommand {
    [cmdletBinding()]
    param([Parameter(Mandatory)][Renci.SshNet.SshClient] $SshClient,
        [scriptblock] $Command,
        [switch] $Status)
    if ($SshClient -and $SshClient.IsConnected -and -not $SshClient.Error) {
        if ($Command) {
            $CommandsToExecute = & $Command
            [string] $SendCommand = foreach ($C in $CommandsToExecute) { if ($C.Trim().EndsWith(';')) { $C } else { "$C;" } }
            try {
                Write-Verbose -Message "Send-SSHCommand - Executing command: $SendCommand"
                if ($Status) {
                    [PSCustomObject] @{Status = $true
                        Output                = $SshClient.CreateCommand($SendCommand).Execute()
                        Error                 = $null
                    }
                } else { $SshClient.CreateCommand($SendCommand).Execute() }
            } catch {
                if ($PSBoundParameters.ErrorAction -eq 'Stop') {
                    Write-Error $_
                    return
                } else { Write-Warning "Send-SSHCommand - Error: $($_.Exception.Message)" }
                if ($Status) {
                    [PSCustomObject] @{Status = $false
                        Output                = ''
                        Error                 = "Error: $($_.Exception.Message)"
                    }
                }
            }
        }
    }
}
function Set-FTPChmod {
    [cmdletBinding(DefaultParameterSetName = 'ByInt')]
    param([Parameter(Mandatory, ParameterSetName = 'ByInt')]
        [Parameter(Mandatory, ParameterSetName = 'Explicit')]
        [FluentFTP.FtpClient] $Client,
        [Parameter(Mandatory, ParameterSetName = 'ByInt')]
        [Parameter(Mandatory, ParameterSetName = 'Explicit')]
        [string] $RemotePath,
        [Parameter(Mandatory, ParameterSetName = 'ByInt')]
        [nullable[int]] $Permissions,
        [Parameter(Mandatory, ParameterSetName = 'Explicit')]
        [FluentFTP.FtpPermission] $Owner,
        [Parameter(Mandatory, ParameterSetName = 'Explicit')]
        [FluentFTP.FtpPermission] $Group,
        [Parameter(Mandatory, ParameterSetName = 'Explicit')]
        [FluentFTP.FtpPermission] $Other)
    if ($Client -and $Client.IsConnected -and -not $Client.Error) { if ($Permissions) { $Client.Chmod($RemotePath, $Permissions) } else { $Client.Chmod($RemotePath, $Owner, $Group, $Other) } }
}
function Set-FTPOption {
    [cmdletBinding()]
    param([Parameter(Mandatory)][FluentFTP.FtpClient] $Client,
        [nullable[int]] $RetryAttempts,
        [nullable[bool]] $DownloadZeroByteFiles)
    if ($RetryAttempts) { $Client.RetryAttempts = $RetryAttempts }
    if ($DownloadZeroByteFiles) { $Client.DownloadZeroByteFiles = $DownloadZeroByteFiles }
}
function Set-FTPTracing {
    [cmdletBinding()]
    param([string] $LogPath,
        [switch] $Enable,
        [switch] $Disable,
        [switch] $ShowPassword,
        [switch] $ShowUsername,
        [switch] $HideIP,
        [switch] $HideFunctions,
        [switch] $DisplayConsole)
    if ($Enable) { [FluentFTP.FtpTrace]::EnableTracing = $true }
    if ($Disable) { [FluentFTP.FtpTrace]::EnableTracing = $false }
    if ($LogPath) { [FluentFTP.FtpTrace]::LogToFile = $LogPath }
    if (-not $HideFunctions) { [FluentFTP.FtpTrace]::LogFunctions = $true }
    if ($DisplayConsole) { [FluentFTP.FtpTrace]::LogToConsole = $true }
    if ($ShowUsername) { [FluentFTP.FtpTrace]::LogUserName = $true }
    if ($ShowPassword) { [FluentFTP.FtpTrace]::LogPassword = $false }
    if (-not $HideIP) { [FluentFTP.FtpTrace]::LogIP = $true }
}
function Start-FXPDirectoryTransfer {
    [alias('Start-FXPDirectory')]
    [cmdletBinding()]
    param([alias('SourceClient')][Parameter(Mandatory)][FluentFTP.FtpClient] $Client,
        [Parameter(Mandatory)][string] $SourcePath,
        [Parameter(Mandatory)][FluentFTP.FtpClient] $DestinationClient,
        [Parameter(Mandatory)][string] $DestinationPath,
        [FluentFTP.FtpFolderSyncMode] $FolderSyncMode = [FluentFTP.FtpFolderSyncMode]::Update,
        [FluentFTP.FtpRemoteExists] $RemoteExists = [FluentFTP.FtpRemoteExists]::Skip,
        [FluentFTP.FtpVerify[]] $VerifyOptions = [FluentFTP.FtpVerify]::None)
    if ($Client -and $Client.IsConnected -and -not $Client.Error) { $Client.TransferDirectory($SourcePath, $DestinationClient, $DestinationPath, $FolderSyncMode, $RemoteExists, $VerifyOptions) }
}
function Start-FXPFileTransfer {
    [alias('Start-FXPFile')]
    [cmdletBinding()]
    param([alias('SourceClient')][Parameter(Mandatory)][FluentFTP.FtpClient] $Client,
        [Parameter(Mandatory)][string] $SourcePath,
        [Parameter(Mandatory)][FluentFTP.FtpClient] $DestinationClient,
        [Parameter(Mandatory)][string] $DestinationPath,
        [switch] $CreateRemoteDirectory,
        [FluentFTP.FtpRemoteExists] $RemoteExists = [FluentFTP.FtpRemoteExists]::Skip,
        [FluentFTP.FtpVerify[]] $VerifyOptions = [FluentFTP.FtpVerify]::None)
    if ($Client -and $Client.IsConnected -and -not $Client.Error) { $Client.TransferFile($SourcePath, $DestinationClient, $DestinationPath, $CreateRemoteDirectory.IsPresent, $RemoteExists, $VerifyOptions) }
}
function Test-FTPDirectory {
    [cmdletBinding()]
    param([Parameter(Mandatory)][FluentFTP.FtpClient] $Client,
        [Parameter(Mandatory)][string] $RemotePath)
    if ($Client -and $Client.IsConnected -and -not $Client.Error) { $Client.DirectoryExists($RemotePath) }
}
function Test-FTPFile {
    [cmdletBinding()]
    param([Parameter(Mandatory)][FluentFTP.FtpClient] $Client,
        [Parameter(Mandatory)][string] $RemotePath)
    if ($Client -and $Client.IsConnected -and -not $Client.Error) { $Client.FileExists($RemotePath) }
}
Export-ModuleMember -Function @('Compare-FTPFile', 'Connect-FTP', 'Connect-SFTP', 'Connect-SSH', 'Disconnect-FTP', 'Disconnect-SFTP', 'Get-FTPChecksum', 'Get-FTPChmod', 'Get-FTPList', 'Get-SFTPList', 'Move-FTPDirectory', 'Move-FTPFile', 'Receive-FTPDirectory', 'Receive-FTPFile', 'Receive-SFTPFile', 'Remove-FTPDirectory', 'Remove-FTPFile', 'Remove-SFTPFile', 'Rename-FTPFile', 'Rename-SFTPFile', 'Request-FTPConfiguration', 'Send-FTPDirectory', 'Send-FTPFile', 'Send-SFTPFile', 'Send-SSHCommand', 'Set-FTPChmod', 'Set-FTPOption', 'Set-FTPTracing', 'Start-FXPDirectoryTransfer', 'Start-FXPFileTransfer', 'Test-FTPDirectory', 'Test-FTPFile') -Alias @('Add-FTPDirectory',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