Note
Azure Active Directory is now called Microsoft Entra ID. The portal labels and steps below reflect the interface at the time of writing.
Note
Azure Active Directory is now called Microsoft Entra ID. The portal labels and steps below reflect the interface at the time of writing.
Warning
This sample is preserved as a historical record. It accepts all certificates and prints authentication data containing an access token to the console. Do not run it as written. Validate certificates, avoid logging authentication data, and manage secrets securely in your implementation.
Warning
This sample is preserved as a historical record. It accepts all certificates and prints authentication data containing an access token to the console. Do not run it as written. Validate certificates, avoid logging authentication data, and manage secrets securely in your implementation.
Warning
This sample is preserved as a historical record. It accepts all certificates and prints authentication data containing an access token to the console. Do not run it as written. Validate certificates, avoid logging authentication data, and manage secrets securely in your implementation.
You can use the Send-MailMessage cmdlet to send email with PowerShell. However, its use is not recommended because the SmtpClient class it uses internally is also not recommended. There is no first-party replacement cmdlet, so to send email to an SMTP server, you need to use a third-party module or create your own SMTP email-sending functionality.
If you want to send email from an Exchange Online mailbox rather than through SMTP, you can use Microsoft Graph. The Microsoft Graph PowerShell SDK, a module for using Microsoft Graph with PowerShell, also provides cmdlets for this purpose.