0
私はデータベースに問い合わせる機能を持っています。私は、クエリの結果を、人間のやりとりなしでExcel形式で電子メールで送信したいと考えています。これは可能ですか?powershellをexcel形式で電子メールで送信するにはどうすればいいですか
$Query="SELECT T1.Author,
T1.Revision,
T1.Msg AS LogNumber,
T1.Path as Checkin,
T2.ThePath as DS_Dependencies
FROM Table AS T1
INNER
JOIN Table AS T2
ON T1.condition = T2.condition"
# redirecting one output stream to the success output stream by using &1
$output = Invoke-Sqlcmd -ServerInstance "sqlInstance" -Database "Database" -Query $Query | Out-String
if ($Output){
Write-Output "Sending Report"
$MailUsername = "abc"
$MailPassword = "xyz"
$cred = New-Object System.Management.Automation.PSCredential -ArgumentList @($MailUsername,(ConvertTo-SecureString -String $MailPassword -AsPlainText -Force))
Send-MailMessage -To "[email protected]" -From "[email protected]" -SmtpServer mail.test.net -Credential $cred -Subject "Hey testing:" -Body "$Output"
}