Based on the comments.
The solution was to use the following command in UserData
:
net user Administrator "new_password"
The command, as explained in the docs, can be used to change admin password.
This works because UserData
executes under administrator account (ref):
User data scripts are executed from the local administrator account when a random password is generated.