Here is a script that may help you with that.
First you need to download Powershell MySQL connector from HERE
Since i don't have MySQL installed on this machine i wasn't able to
test the code. ( the MySQL connection and insertion is from HERE
function ConnectMySQL([string]$user,[string]$pass,[string]$MySQLHost,[string]$database) {
# Load MySQL .NET Connector Objects
[void][system.reflection.Assembly]::LoadWithPartialName("MySql.Data")
# Open Connection
$connStr = "server=" + $MySQLHost + ";port=3306;uid=" + $user + ";pwd=" + $pass + ";database="+$database+";Pooling=FALSE"
$conn = New-Object MySql.Data.MySqlClient.MySqlConnection($connStr)
$conn.Open()
$cmd = New-Object MySql.Data.MySqlClient.MySqlCommand("USE $database", $conn)
return $conn
}
function WriteMySQLQuery($conn, [string]$query) {
$command = $conn.CreateCommand()
$command.CommandText = $query
$RowsInserted = $command.ExecuteNonQuery()
$command.Dispose()
if ($RowsInserted) {
return $RowInserted
} else {
return $false
}
}
$user ="test"
$pass = "VeryStrongPassword"
$MySQLHost = "Localhost"
$database = "MyDB"
# Connect to MySQL Database
$conn = ConnectMySQL $user $pass $MySQLHost $database
Get-ItemProperty C:\file.csv | select Name, CreationTime, Length, DirectoryName | %{
$query = "INSERT INTO Table SET file_name='"+$PSItem.Name+"', file_size='"+$PSITEM.Length+"', file_creationdate='"+$PSitem.CreationTime+"', file_dir='"+$PSItem.DirectoryName+"'"
# Insert into MYSQL
$Rows = WriteMySQLQuery $conn $query
Write $Rows " inserted into database"
}