Skip to content

Commit fb45c6f

Browse files
authored
Notify password expiry (#1551)
* Create script.js * Create readme.md
1 parent b675d4b commit fb45c6f

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
This script will work to notify the users if their password is going to expire in less than 7 days.
2+
Prerequisite : You will need to create an event first.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
var userGR = new GlideRecord('sys_user');
2+
userGR.query();
3+
while (userGR.next()) {
4+
var expiryDate = new GlideDateTime(userGR.password_needs_reset_by);
5+
var today = new GlideDateTime();
6+
var diff = GlideDateTime.subtract(expiryDate, today);
7+
8+
// Check the difference in days
9+
if (diff.getDays() < 7) {
10+
gs.eventQueue('password_expiry', userGR, 'Your password will expire in ' + diff.getDays() + ' days.', '');
11+
}
12+
}

0 commit comments

Comments
 (0)