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 |
Body
以下の様な結果が送信されてくる。
Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName
------- ------ ----- ----- ------ -- -- -----------
277 15 3024 3480 0.41 9164 1 AdobeCollabSync
408 21 5652 7164 172.25 11052 1 AdobeCollabSync
489 34 55676 24572 18088 0 aspnet_state
283 22 22616 38320 0.47 576 1 chrome
359 33 68852 96620 6.13 1192 1 chrome
....
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
実行方法
参考
PowerShellを使って、SMTPでGmailを送信する - メモ的な思考的な
http://thinkami.hatenablog.com/entry/2016/07/09/075608
SE'S BOOK: Powershellで電子メールを送信する
https://viewse.blogspot.com/2012/12/powershell_22.html