How to logout all the active session users from the instance using script?

siva krishna M2
Tera Guru
Whenever user login to the instance, a user session record will be created. we can lock out session for the user so that user will be logged out from the session when he tries for any transaction on the instance
 
var sessions = new GlideRecord('v_user_session');
sessions.addQuery('user','!=',gs.getUserName())
sessions.query();
while(sessions.next())
{
    sessions.locked=true;
    sessions.update();
}
 
Usually we can use this script whenever we implement new features in the instance and which needs relogin of the user to make them effective to the users.
1 REPLY 1

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @siva krishna M2 

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0760410

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************