Posted on 04-09-2024 02:08 PM
We are pretty new to Jamf and still trying to understand the scripting. We have a renamecomputer script that we got as part of our onboarding for computers. Was working great till we started sending in the department on the user from Okta. So now the naming is off. I am pretty good at Powershell and C#, but bash scripts I am struggling with. Is there way in a bash script to look up a department value in like a switch statement?
example if the department is "IT", then can you do something like this?
switch (department)
case "irs":
value = 123
case "IT":
value = 987
Any help or pointers to reference links would be great. I am not sure what the bash term would be to do that so if I can get someone to help with that, might be able to get this figured out.
Solved! Go to Solution.
Posted on 04-09-2024 04:50 PM
BTW, there is in fact such a thing in bash/zsh as a case statement, similar to what you posted above.
Example:
department="somevalue"
case "$department" in
irs)
value="123"
;;
IT)
value="987"
;;
esac
You can add as many of these to the case statement as you need to.
Posted on 04-09-2024 04:46 PM
Hi there! It might help us if you posted the existing script you're using right now, just for reference.
I guess I'm not quite understanding how including department information from Okta is causing the rename script to not work as expected, but that could be because I don't use Okta, so I'm not that familiar with it.
Posted on 04-10-2024 06:20 AM - last edited on 04-10-2024 07:07 AM by kohner_johnson
*Removed
Posted on 04-10-2024 06:50 AM
Just sent you a PM - not sure if you have notifications set up, so posting a message here too
Posted on 04-09-2024 04:50 PM
BTW, there is in fact such a thing in bash/zsh as a case statement, similar to what you posted above.
Example:
department="somevalue"
case "$department" in
irs)
value="123"
;;
IT)
value="987"
;;
esac
You can add as many of these to the case statement as you need to.
Posted on 04-10-2024 06:22 AM
That is exactly what I was looking for. Thank you!