If your script is specifically using ~/.bash_profile and similar for the .zshrc file as the path, then it's not going to work. In scripts run from Jamf Pro you cannot use the ~ as part of a path, since that automatically resolves to the home path of whoever is calling the command. With a Jamf Pro run policy, that's going to be root, so ~/.bash_profile actually becomes /private/var/root/.bash_profile
To fix this, you have to 1) get the logged in user's name, then either run all the commands that are adding entries into their bash and zsh profile as them, or 2) run the script as root but point to the full path of those files, as in /Users/$loggedInUser/.bash_profile
The problem with the second method is you'll need to add in some extra lines to ensure the user owns those files. By default they'll be owned by root and the user account may not even be able to read from them, or make any changes to them. Use chown and chmod to adjust the ownership and permissions on the files if you choose to use the second method.
If your script is specifically using ~/.bash_profile and similar for the .zshrc file as the path, then it's not going to work. In scripts run from Jamf Pro you cannot use the ~ as part of a path, since that automatically resolves to the home path of whoever is calling the command. With a Jamf Pro run policy, that's going to be root, so ~/.bash_profile actually becomes /private/var/root/.bash_profile
To fix this, you have to 1) get the logged in user's name, then either run all the commands that are adding entries into their bash and zsh profile as them, or 2) run the script as root but point to the full path of those files, as in /Users/$loggedInUser/.bash_profile
The problem with the second method is you'll need to add in some extra lines to ensure the user owns those files. By default they'll be owned by root and the user account may not even be able to read from them, or make any changes to them. Use chown and chmod to adjust the ownership and permissions on the files if you choose to use the second method.
thanks for your reply once again, leading me down the correct path. I made it so that the script saves another script onto the machine in the /private/tmp folder and then chmods and chowns and runs the script as the current logged in user and then deletes the script.