首页 > 解决方案 > 运行 powershell 脚本,以便检查并邮寄故障

问题描述

我正在运行一个包含许多成员的 Office 365 数据库,每个成员都在一组组中。我曾经手动检查组和用户,但现在成员太多,无法有效地做到这一点。现在我在 github 上的某个地方找到了一个 powershell 脚本,但它看起来好像只是在 powershell 中进行检查和显示。有没有办法让脚本比较用户和组,如果用户在组中,他不属于向域中的管理员邮件发送邮件?如果这有任何意义...

标签: powershelloffice365

解决方案


您可以使用这段代码在 powershell 中发送电子邮件。

$smtpServer = "mailserver.com"
$From = "from@mailserver.com"
$To = "to@example.com"
$Subject = "example"
$body = "test"
send-mailmessage -to $To -from $From -subject $Subject -SmtpServer $smtpServer -Body $body -BodyAsHtml -Port 25

推荐阅读