Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Copy and paste a script that isn't available in the manual for the paid course.

Alan42
Tera Guru

The Evantage lab guide says to copy and paste a script that isn't available in the manual for the paid course. Specifically to check the KB for text. There's nothing in the ServiceNow knowledge base for cleanup scripts. Where am I supposed to go for this and other mandatory information? Right now I am stuck on Lab 1.2 Clone an instance., step D. Student (source) Instance: Create Cleanup Scripts.

 

This is the ServiceNow Administration Advanced course.      

 

1 ACCEPTED SOLUTION

Sandeep Rajput
Tera Patron
Tera Patron

@Alan42 If you are just looking for the script then here it is.

var gr_lock_out_non_admins = new GlideRecord("sys_user");
gr_lock_out_non_admins.addEncodedQuery("roles!=admin");
gr_lock_out_non_admins.query();
while (gr_lock_out_non_admins.next()) {
    gr_lock_out_non_admins.locked_out = true;
    gr_lock_out_non_admins.update();
}

View solution in original post

5 REPLIES 5

Sandeep Rajput
Tera Patron
Tera Patron

@Alan42 If you are just looking for the script then here it is.

var gr_lock_out_non_admins = new GlideRecord("sys_user");
gr_lock_out_non_admins.addEncodedQuery("roles!=admin");
gr_lock_out_non_admins.query();
while (gr_lock_out_non_admins.next()) {
    gr_lock_out_non_admins.locked_out = true;
    gr_lock_out_non_admins.update();
}

Thank you.   Do you know where this is documented?   I don't know if there are similar copy and paste scenarios later on in the course.     

Sandeep Rajput
Tera Patron
Tera Patron

@Alan42 Sorry no documentation is available with me. If similar scenario occurs then create a post and tag me in the same along with the screenshot. I will extract the code for you.

Alan42
Tera Guru

Thank you again.  The support team has provided documents that can be copied and pasted from.     Hopefully these will help others.