Hello Andyve,
Some questions for the issue:
1. If you manually clone a VM from template VM and manually run your script with root, after that, can domain user authetnication work?
2. Would you please add some lines in your script to write the execution to a log file so that we can check if the script was executed successfully?
Tiddy