Created
February 14, 2025 03:40
-
-
Save eyasuyuki/ef3d9a092272bb35482038c0c3083d2f to your computer and use it in GitHub Desktop.
Windows再起動時にメールする
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
$SMTPServer = "smtp.gmail.com" | |
$SMTPPort = 587 | |
$Sender = "[email protected]" | |
$Recipient = "[email protected]" | |
$Username = "[email protected]" | |
$Password = "アプリパスワード(16桁)" # 取得したアプリパスワードを入力 | |
$Subject = "Windows再起動通知" | |
$Body = "PCが再起動されました。日時: $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" | |
$SecurePassword = ConvertTo-SecureString $Password -AsPlainText -Force | |
$Credential = New-Object System.Management.Automation.PSCredential($Username, $SecurePassword) | |
Send-MailMessage -To $Recipient -From $Sender -Subject $Subject -Body $Body -SmtpServer $SMTPServer -Port $SMTPPort -UseSsl -Credential $Credential |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
public