How to create script for changing password instead of doing it manually?

How to create script for changing password instead of doing it manually. I am tired of doing this again and again. There should be away. I googled but could not get enough exposure.

It is an optional task. Please try it on your own.

Yes Sir I know that it is an optional task but I just want some help. That’s all otherwise I am continuing in my module progress.