Script that automatically changes the "User Principal Name" of a user based on the "company" attribute

Script that automatically changes the "User Principal Name" of a user based on the "company" attribute

Good day,

Is it possible to create a script that automatically changes the "User Principal Name" of a user based on the "company" attribute in the module "User Creation Templates"?
In my case we create users with different "UPN" and each UPN corresponds to one of the companies of the group.

For example:
- Pedro Pérez is from the company "ABC", then his UPN at the time of creating it should be " pperez@abc.com"

- Luis Sojo is from the company "TRC", then his UPN at the time of its creation should be " pperez@trc.com"

                New to ADSelfService Plus?