No, the FlexEngine (UEM agent) runs in the same security context as the user. So this script fails because of limited permissions.
Typically such system changes are made by a System Management tool like SCCM, and not by a User Management tool.
Or you could incorporate them in the golden image if you use VDI.