Drupal - Reset user password without using "Forgot password?"
It's easier these days:
$account = \Drupal::entityTypeManager()->getStorage('user')->load(1);
$account->setPassword('new password');
$account->save();
Alternately, since you seem to be running this as a standalone script, there is a Drush (9.x) command
drush user:password admin mynewpassword
For Drush 8.x and earlier::
drush user-password admin --password=newpass