Setting a Salesforce User Password via Developer Console (Apex)

If you would like to quickly set a temporary password for a user, you can do so in the Developer Console.
Get the user via a query (you can use a more specific WHERE clause; in my case, I am just querying based on the user’s name)
SELECT Id FROM User WHERE Name = 'argen'
Developer Console > Query Editor > Execute
Copy the Id from the query result and paste the following Apex code into the Anonymous Window (or simply run CTRL + E if you are on Windows or CMD + E if you are on Mac).
String userId = '005***************'; // In your case, you will paste the full Id. String tempPassword = 'tempPassword123!'; // Password we set for the user. System.setPassword(userId, tempPassword);
Click the “Execute” button at the bottom right.
You can log in with the new password. Please follow this approach only in Sandbox or Development environments. Also, make sure the user is active and not frozen.

![[TIL] Javascrip Dev 1 - Summer '23 Review Notes](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fstock%2Funsplash%2Fg5jpH62pwes%2Fupload%2Ff6e5ea3bf48125018578ac2d51a1852f.jpeg&w=3840&q=75)

