Would you like to learn how to send an email using Powershell and Gmail? In this tutorial, we are going to show you how to use Powershell to send email notifications using the command-line on a computer running Windows.

• Windows 2012 R2
• Windows 2016
• Windows 2019
• Windows 10

Equipment list

The following section presents the list of equipment used to create this tutorial.

As an Amazon Associate, I earn from qualifying purchases.

Related tutorial - PowerShell

On this page, we offer quick access to a list of tutorials related to PowerShell.

Tutorial - Gmail Integration

First, we need to enable your Gmail account to receive connections from external programs.

Open your browser and access your Gmail account.

In our example, the following URL was entered in the Browser:

http://gmail.google.com

On the login screen, enter your Gmail username and password.

Gmail account

After the login, you need to access the following URL:

https://myaccount.google.com/signinoptions/two-step-verification

Enable the two step verification on this account.

After enabling the two step verification, you need to access the following URL:

https://security.google.com/settings/security/apppasswords

Create an application password.

Select the Gmail application and the type of device: Other.

gmail app password

In our example, we named the device POWERSHELL.

Click on the Generate button and take note of the randomly generated password.

Google generate app password

Next, you need to access the following URL:

https://accounts.google.com/DisplayUnlockCaptcha

Click on the Continue button to enable external access to your Google account.

gmail display unlock captcha

You have finished the required steps for the Gmail integration.

The Gmail integration will solve the following error.

Copy to Clipboard

It will also solve this error.

Copy to Clipboard

You have finished the Gmail integration.

Tutorial Powershell - Send email using Gmail

Use the Powershell command-line to send an email using Gmail.

Copy to Clipboard

Enter the Gmail account credentials.

Powershell - Email credentials

If the test was successful, you will receive the sent message.

Powershell - Send email Gmail

Send the email with an attachment using Powershell.

Copy to Clipboard

Use Powershell to send an email using Gmail and a stored credential.

Copy to Clipboard

Use Powershell to send an email using Gmail and a credential.

Copy to Clipboard

Congratulations! You are able to use PowerShell to send emails using Gmail.