function Execute-MySQLNonQuery($conn, [string]$query) {
$command = $conn.CreateCommand() # Create command object
$command.CommandText = $query # Load query into object
$RowsInserted = $command.ExecuteNonQuery() # Execute command
$command.Dispose() # Dispose of command object
if ($RowsInserted) {
return $RowInserted
} else {
return $false
}
}
function UploadCSV_SQL() {
$Dir=”C:\CSVLogs”
#ftp server
$ftp = ‘FTPServer’
$user = ‘UserName’
$pass = ‘PassWord’
$webclient = New-Object System.Net.WebClient
$webclient.Credentials = New-Object System.Net.NetworkCredential($user,$pass)
#list every sql server trace file
foreach($item in (dir $Dir “*SQL – $date.csv”)){
“Uploading $item…”
$uri = New-Object System.Uri($ftp+$item.Name)
$webclient.UploadFile($uri, $item.FullName)
}
}
function DownloadCSV_SQL() {
$Dir=”C:\CSVLogs”
#ftp server
$ftp = ‘FTPServer’
$user = ‘UserName’
$pass = ‘PassWord’
$webclient = New-Object System.Net.WebClient
$webclient.Credentials = New-Object System.Net.NetworkCredential($user,$pass)
#list every sql server trace file
foreach($item in (dir $Dir “*.trc”)){
“Uploading $item…”
$uri = New-Object System.Uri($ftp+$item.Name)
$webclient.DownloadFile($uri, $item.FullName)
}
}
