これは、編集して電子メールアドレスとその他の交換でエクスポートされたpowershellのものをmysqlに追加できるスクリプトです
[void][System.Reflection.Assembly]::LoadWithPartialName("MySql.Data")
$servers = Get-MailboxServer
foreach($server in $servers)
{ $mailboxes = Get-Mailbox -server $server -ResultSize unlimited
foreach ($m in $mailboxes)
{ $stats = Get-MailboxStatistics $m | Select ItemCount,DeletedItemCount,TotalItemSize,TotalDeletedItemSize
$date = Get-Date -Format "dd MMM yyyy h:mmtt"
$alias = $m.Alias
$items = $stats.ItemCount
$deletedItems = $stats.DeletedItemCount
$size = $stats.TotalItemSize.Value.ToMB()
$deletedSize = $stats.TotalDeletedItemSize.Value.ToMB()
$dbconnect = New-Object MySql.Data.MySqlClient.MySqlConnection
$dbconnect.ConnectionString = "server=<SERVER>;port=3306;uid=<USERNAME>;pwd=<PASSWORD>;database=<DATABASE>;"
$dbconnect.Open()
$sql = New-Object MySql.Data.MySqlClient.MySqlCommand
$sql.Connection = $dbconnect
$sql.CommandText = "INSERT INTO <TABLE> (Timestamp,Alias,ItemCount,TotalItemSize,DeletedItemCount,TotalDeletedItemSize) values ('" + $date + "','" + $alias + "','" + $items + "','" + $size + "','" + $deletedItems + "','" + $deletedSize + "')"
$sql.ExecuteNonQuery()
$dbconnect.Close()
}
}