Script/Way to lockout all active users

pradnyajamgaonk
Tera Contributor

Hi All,

We want to lockout/deactivate/disable all active users at a time in a SNOW instance.

Kindly suggest possible ways to mass update all active SNOW users to Locked out =TRUE/Active = FALSE.

Thanks and Regards,

Pradnya

4 REPLIES 4

marcguy
ServiceNow Employee
ServiceNow Employee

anurag92
Kilo Sage

The background script would be:



var gr = new GlideRecord("sys_user");


gr.addQuery("active", "true");


gr.query();


while (gr.next()) {


    gr.locked_out=true;


gr.update();


}



But if you want to just prevent users from logging in to Serivcenow, there is another way too. You can edit the glide.login.home and put a custom error page there.


Hi Anurag,



Thanks for your reply.



But can you pleaes provide detailed steps to execute this as I am quite new to use Servicenow.



Thanks & Regards,


Pradnya


anurag92
Kilo Sage

1. Pre-Requisites: You need security_admin role


2. Once you have security role,activate Elevated privileges   (by unlocking the lock near Impersonation icon) or in new UI16 you can do by clicking on the name menu


3. Once Elevated privileges are active, go to 'Scripts - Background' and run this script.


4. Also, go through the link mentioned by mguy.



Mark as Helpful or Correct as it suits you.