Check PowerShell Scripts for deprecated Azure AD or MSOnline Cmdlets

You might have read it a few times… The Azure AD and MSOnline PowerShell modules are deprecated, and scripts that use Cmdlets from these modules should be updated to use Microsoft Graph Cmdlets. In this blog post, I will show you a script to scan for them and also which replacement Cmdlets you should use instead.

Using Send-MgUserMail as the Send-MailMessage replacement

I have often used the Send-MailMessage cmdlet to test Receive Connectors in Exchange or email reports in scheduled PowerShell scripts. When you try to use the Send-MailMessage cmdlet, it has been showing you this message for quite a while now: WARNING: The command 'Send-MailMessage' is obsolete. This cmdlet does not guarantee secure connections to SMTP servers. While no immediate replacement is available in PowerShell, we recommend you not use Send-MailMessage. See https://aka.ms/SendMailMessage for more information. In this blog post, I will show you the new way of sending emails using Send-MgUserMail.