Last active
January 16, 2019 07:38
-
-
Save daisukenishino2/d16adc4a23aecbcb00b70b6035429699 to your computer and use it in GitHub Desktop.
ps aux | mail -s ... みたいなことをやるには...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$mail = @{ | |
from = "hoge@hoge-solutions.com"; | |
to = "hoge@hoge-solutions.com"; | |
smtp_server = "smtp.gmail.com"; | |
smtp_port = 587; | |
user = "hoge@gmail.com"; | |
password = "xxxxxxxx"; | |
} | |
$password = ConvertTo-SecureString $mail["password"] -AsPlainText -Force | |
$credential = New-Object System.Management.Automation.PSCredential $mail["user"], $password | |
Send-MailMessage -To $mail["to"] ` | |
-From $mail["from"] ` | |
-SmtpServer $mail["smtp_server"] ` | |
-Credential $credential ` | |
-Port $mail["smtp_port"] ` | |
-Subject "subject" ` | |
-Body ((Get-process) | out-string) ` | |
-Encoding UTF8 ` | |
-UseSsl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Body
以下の様な結果が送信されてくる。