3 weeks ago
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.
3 weeks ago
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.
3 weeks ago
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.
3 weeks ago - last edited 3 weeks ago by kohner_johnson
*Removed
3 weeks ago
Just sent you a PM - not sure if you have notifications set up, so posting a message here too
3 weeks ago
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.
3 weeks ago
That is exactly what I was looking for. Thank you!