Posted on 09-19-2024 12:10 AM
I’m currently developing a remediation policy for Self Service that triggers the uninstall and reinstall of a profile. While I can successfully remove and reinstall the profile, I need a verification step to check if the profile was reinstalled. I'm using the following command:
bash
profiles show -o stdout | grep "ProfileDisplayName = "$profileName"" | /usr/bin/awk '{print $3}' | sed 's/[[:punct:]]//g'
This works perfectly for single-word profile names, like "Zoom," but fails with multi-word names, such as "Zoom Profile," resulting in "no such file or directory." I’ve tried enclosing the profile name in both single and double quotes, and using "${profileName}", but nothing seems to work.
Could anyone suggest how to modify the command so it successfully handles profile names with more than one word? Here’s the function I created for verification:
bash
function checkInstall() {
installed=$(profiles show -o stdout | grep "ProfileDisplayName = "$profileName"" | /usr/bin/awk '{print $3}' | sed 's/[[:punct:]]//g')
if [ "$installed" = "$profileName" ]; then
log "Profile "$profileName" was installed successfully"
elif [ "$installed" != "$profileName" ]; then
log "Profile "$profileName" install failed"
fi
}
Thanks for your help!
Regards
Darshan Hiranandani
Posted on 09-19-2024 01:13 AM
You’re probably be better off grepping for the UUID of the profile instead.
Posted on 09-19-2024 04:45 AM
Almost this exact question was asked last week, strange. However, there is a solution in that post you should probably look at.
Solved: How to grep a profile named with more than one wor... - Jamf Nation Community - 324834
Posted on 09-19-2024 05:08 AM
I tend to prefer the unique identifier as the profile name can change, it also avoids issues with non-alpha characters
Posted on 10-08-2024 10:57 AM
try this
profiles show -o stdout | grep "ProfileDisplayName" | grep "$profileName"