Skip to content

Instantly share code, notes, and snippets.

@eyasuyuki
Created February 14, 2025 03:40
Show Gist options
  • Save eyasuyuki/ef3d9a092272bb35482038c0c3083d2f to your computer and use it in GitHub Desktop.
Save eyasuyuki/ef3d9a092272bb35482038c0c3083d2f to your computer and use it in GitHub Desktop.
Windows再起動時にメールする
$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
@eyasuyuki
Copy link
Author

public

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment