
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
07-01-2022 06:30 AM - edited 06-26-2024 05:50 AM
Password Setting and Generation
ServiceNow's San Diego version simplifies password creation for administrators. An out-of-the-box (OOB) script, included as part of the password policy, automates password generation. This eliminates the manual burden of creating secure passwords for each user.
var username = 'itil';
var password = SNC.PasswordPolicyEvaluator.generateUserPassword(username);
gs.print(password) // to view the password
var result = SNC.PasswordPolicyEvaluator.setUserPassword(username, password);
setUserPassword - This sets the password which is generated above and ticks the password needs reset field.
If there is any other script which is used to set the password then this additional line can help in validating if the generated pass is as per the policy. The script returns true/false
var isValid = SNC.PasswordPolicyEvaluator.isValidPwdPerPolicy('password string', '3054afe6737a3300616ca9843cf6a735'); // sysid of the password policy
sometimes the length of the password could be crazy. I've seen a generated pass with 77 char, In order to adjust the length of the passwords.
Go to Password Policy > Open the default > set max char to lower number (default 100)
Video Link - https://www.youtube.com/watch?v=cDIMEcA6Uuo
Thanks,
Murali
- 5,481 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Does "SNC.PasswordPolicyEvaluator.isValidPwdPerPolicy()" only work for global applications?
Can you tell me if there is a way to use it in a scope application?

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi @Ohki_Yamamoto , No I don't know any equivalent for the scoped app. This only works on the global app and we don't have access to PasswordPolicyEvaluator.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Kilo ,Thank you very much.
I understand that it is available only for global applications.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
@Muralidharan BS @Ohki_Yamamoto Password generate script only working for admin user. How I can do it for non admin user?

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
@Alok Sharma , It works for all the users, in the above script I tried for an ITIL user and it worked.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
@Muralidharan BS Thanks for your quick response. When I am trying to trigger SNC.PasswordPolicyEvaluator.generateUserPassword(userName); from non admin then it's returning as null. For admin it's working fine.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Is there more product documentation regarding what information can be pulled from the SNC.PasswordPolicyEvaluator API? I'm looking to manually generate valid passwords based on a minimum length provided by the password policy to make it easy to copy while also allowing for a maximum of 100+ characters in a password. I'd rather not use the automatic generator provided as it can provide wild ranges of character lengths