web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Send Password Expiry N...
Power Automate
Answered

Send Password Expiry Notification to user

(0) ShareShare
ReportReport
Posted on by 125
Hello Folks,
 
Greetings!
 
I'm planning to build a Power Automate flow that sends notifications to Microsoft Teams users whose Office 365 passwords are set to expire within the next 7 days. I found that Microsoft Graph API can be used to retrieve all users in the organization. However, since our organization has over 22,000 users, validating each one through Power Automate poses significant risks—such as API throttling, timeouts, or potential flow failures due to volume.

Is there a more efficient way to implement this functionality using Power Automate, or would you recommend an alternative approach?

 

Thanks in advance!

 
Categories:
I have the same question (0)
  • Tomac Profile Picture
    4,138 Moderator on at
     
    Are you able to filter the results in the Graph API call directly? If so, you could use the API call to only pull users with passwords expiring in the next 7 days, which would solve the issue.
     
    If you post a screenshot of the action with the API call, we can better help resolve since we'll know what API endpoint and arguments you're using.
  • sachinsoni441 Profile Picture
    125 on at
  • Suggested answer
    Tomac Profile Picture
    4,138 Moderator on at
    Try this:
    https://graph.microsoft.com/beta/users?$filter=accountEnabled%20eq%20true%20and%20userType%20eq%20%27Member%27%20and%20lastPasswordChangeDateTime%20lt%20%27@{addDays(utcnow(),-83,'yyyy-MM-dd')}%27&$select=id,displayName,userPrincipalName,lastPasswordChangeDateTime&$top=999
    I added a filter argument for lastPasswordChangeDateTime is less than (older than) today minus 83 days. This will get all users who haven't change their password in the last 83 days, so assuming your password expiration policy is set to 90 days, it will return users who are within 7 days or their password has already expired. You can use the change I made as an example to set another filter for passwords last changed greater than 90 days so it only gets the users with an upcoming expiration.
     
    If this resolves your issue, please remember to mark it as the answer to help future users searching for a solution to this problem.
  • sachinsoni441 Profile Picture
    125 on at
    Hi @tomac,
     
     
    It appears that the 'lastPasswordChangeDateTime' property cannot be used in custom filter queries within the API.
     
    lastPasswordChangeDateTime
  • Verified answer
    VictorIvanidze Profile Picture
    13,081 on at
    Use this request:
     
    https://graph.microsoft.com/v1.0/users?$count=true&$top=999&$select=displayName,mail,lastPasswordChangeDateTime&$filter=mail ne null and userType  eq 'Member' and assignedLicenses/$count ne 0
  • Suggested answer
    Tomac Profile Picture
    4,138 Moderator on at
    On further investigation it looks like the Graph API can't filter on and form of password expiry, so given the size of your environment I don't think Power Automate is the best solution. It can be done, using Pagination and a Do...Until loop to ensure you go through the entire user directory, but this MS Dev Blog post about how to accomplish this via PowerShell looks like a better solution.
  • VictorIvanidze Profile Picture
    13,081 on at
     
    I've got a ready to use flow with this functionality. If you are interested in cooperation, please contact  me directly.
  • VictorIvanidze Profile Picture
    13,081 on at
    Hi again @sachinsoni441,
     
    as you have 22000 users, read this brilliant article: https://powerrightsolutions.com/paginate-records-efficiently-in-power-automate/

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 468

#2
Haque Profile Picture

Haque 370

#3
Valantis Profile Picture

Valantis 354

Last 30 days Overall leaderboard