Setting up user account for the first time with automise

Hello, We are using Amazon AWS Cloudformation templates to spin up a network. The network consists of a few windows servers. The cloudformation template is executing a script on the windows machine (which is using a blank windows 2016 server template) to install the automise runner, then execute the automise script.
If we login to the machine by hand, and execute the automise script it works fine. If we trigger the script execution from the cloudformation template we get the following error

Googling the problem seems to indicate that this is because the user account is no set up. And indeed, if we login via RDP for the first time, it makes us wait a bit while it is “setting up the account” and then executing the script works fine by hand. To reiterate, the user is created, just we have no logged in yet via RDP, so I think windows has not created all the folders and other settings in the userData that it does when you login the first time

Have you encountered something like this before and can suggest a solution?

I have not seen this before, but I have seen other issues with new account where things like the user profile folder not existing etc.

I suspect windows does some root certificate updates on first login, but so far haven’t found any way to confirm this.

I’m wondering if it’s possible with aws to run something on the machine remotely and asking it to load the users profile, that would probably have the same effect as logging in via rdp?

We have figured out some parameters to use on the CFT script that does just that, i.e. sets up the user profile before running the commands. Thanks!