Salesforce Password Reset – Bulk Reset

 Hi Trailblazers!

Many times we find ourselves in a scenario where we may need to reset passwords for multiple users.

The below code is a rough idea of how this could be achieved :

changepassword ch= new changepassword();


public class ChangePassword 
{
    public changepassword()
    {
        List<User> userList = new List<User>();
        userList = [SELECT Id from User WHERE IsActive = true ];
        
		for(User usr : userList)
                {
                      System.setPassword(usr.Id, 'xxxxxxxx');
                      System.debug('DONE: ' + usr.Id);
                }
    }
    
    
}

This can be executed from the developer console.

In the developer console :

  • Select Debug
  • Open Execute in Anonymous Window

Please execute :

changepassword ch= new changepassword();

I have not added an actual password so please update “xxxxxxxx”
Happy Trails!