嗨,我正在尝试输出 if/else 语句的结果,该语句会将结果从另一个文本文件输出到电子邮件的主题行和正文中。我可以让它输出到 powershell 窗口,但我不知道如何让它把它放在电子邮件的主题行和正文中。我对powershell还是很陌生,所以任何帮助都会很棒。
谢谢,
-缺口-
# Check if the migrater is running
$processToCheck = "calc"
$process = Get-Process $processToCheck
If (!($process))
# Check what step in the process its in
{
$Service = get-content c:\AmicasToolService.properties | select-string "#AmicasService.processes=ArchiveRetrievalTool"
If ($Service) {"is done migrating"}
Else {"is done retrieving"}
# Send Email With Results
$From = "Olorin Migration Status <olorinmigration@gmail.com>"
$To = "nwarner@rchsd.org"
$SMTPServer = "smtp.gmail.com"
$SMTPPort = "587"
$Username = "email@gmail.com"
$Password = "password"
$subject = "Tape"+" "+(select-string "000..." c:\amicas2\config\ArchiveMigration.properties | select -Expand Matches | Select -Expand Value) + ($step)
$body = "Tape"+" "+(select-string "000..." c:\amicas2\config\ArchiveMigration.properties | select -Expand Matches | Select -Expand Value) + " " + "has finished retrieval or migration to Centera. Please check the log in the COA PACS folder for information on which step it is on in the process. \\naspfs01\Depts\ISD\COA\PACS\PACS_Library.xlsx"
$smtp = New-Object System.Net.Mail.SmtpClient($SMTPServer, $SMTPPort);
$smtp.EnableSSL = $true
$smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password);
$smtp.Send($From, $To, $subject, $body);
}