#-----Initier une connexion à l'instance SQL Server 
#-----Attention sous Powershell 7 il faut activer TCP/IP
$sqlinstance = "<OXADWDB_HOST>"
$DatabaseName = "<OXADWDB_DATABASE>"
$username = '<OXADWDB_USER>'
$password = '<OXADWDB_PASSWORD>'
$CsvPath=

$password_secured = ConvertTo-SecureString $password -AsPlainText -Force

# Créer l'objet PSCredential
$credential = New-Object System.Management.Automation.PSCredential($username, $password_secured)

Set-DbatoolsInsecureConnection
$MyConnection = Connect-DbaInstance -SqlInstance $sqlinstance -SqlCredential $credential #-TrustServerCertificate 

#------------Vérification de la connexion 
if ($connection) { 
    Write-Host "Connexion OK SQL $serverName" 
} else { 
    Write-Host "KO de la connexion" 
}

#------------bulk dans la table
Import-DbaCsv -Path "%_etc%BDD_OXADWDDB_EN.oxa" -SqlInstance <OXADWDB_HOST> -Database <OXASQLDB_DATABASE> -Table "TEMP_OXAETL_TEMP_JPM" -AutoCreateTable -Truncate -SkipEmptyLine -Delimiter "|" -SqlCredential $credential



