You must first connect to Microsoft Graph.
-
Using Delegated Access
Connect-MgGraph -Scopes 'User.Read.All', 'Mail.Send', 'Domain.Read.All'
-
Using App-Only Access with Certificate
Connect-MgGraph -ClientId <client ID> -TenantId <tenant ID> -CertificateThumbprint <thumbprint>
Open the script in the editor and modify these values.
Note: If you're using Delegated Access, the
$SenderEmailAddress
must be the logged in user's email address.
$PasswordNotificationWindowInDays = @(31, 17, 14, 10, 5, 3, 1)
$SenderEmailAddress = 'EMAIL ADDRESS HERE'
Run the script. No parameters required.
.\Invoke-PasswordExpirationNotification.ps1