运行powershell脚本,以便它检查并邮寄故障

时间:2019-03-12 09:01:41

标签: powershell office365

我正在运行一个由许多成员组成的Office 365数据库,每个成员都是一组。我曾经手动检查组和用户,但是现在有太多成员无法有效地执行此操作。现在我在github上的某个地方找到了一个powershell脚本,但看起来好像只是在powershell中进行检查和显示。 有没有一种方法可以让脚本比较用户和组,如果用户不在组中,则他不属于该组,将邮件发送到域中的管理邮件吗? 如果这有意义的话...

1 个答案:

答案 0 :(得分:1)

您可以使用这段代码在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