Soufian Manai
Soufian Manai

Reputation: 49

run the powershell script so it checks and mails the faults

I am running an office 365 database of a lot of members, each in one of a bunch of groups. I used to check the groups and users by hand but there are too many members now to be able to do that efficiently. now I have found a powershell script somewhere on github but it looks as if it just does checking and displaying in powershell. Is there a way to have a script compare the users and groups and if a user is in a group he does not belong in send a mail to the admin mail in the domain? if this makes any sense...

Upvotes: 0

Views: 30

Answers (1)

Rhyldin
Rhyldin

Reputation: 11

You can use this piece of code to send an email in powershell.

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

Upvotes: 1

Related Questions