1

This is part of a much larger diagnostic tool I am building. I manage Macs at work and I need to confirm that configuration profiles are all installed or display a list of the ones missing. Scripting is not my strong suit but I am trying to learn. After days of trial and error, I was finally able to get code working, but I am getting output that doesn't make sense. The comparison check I have that works perfectly for most of the profiles, is returning some false failures. I know it is really my failure, but I am not a computer, so there is a detail I am missing, clearly.

Here is a rundown of the code...

$profileList is a control array containing the names of configuration profiles I want to ensure are present. I created this list by running the command:

profiles -C -v | grep attribute | awk '/name/{$1=$2=$3=""; print $0}' | sed -e 's/^[ \t]*//'

on a "known good" machine and putting the names returned in quotes. $missingProfiles is an empty array where I will store the names of profiles not found so they can be displayed in a report.

I altered code slightly as a means to troubleshoot the comparison. Just removed some lines that set variables for use elsewhere in the much longer script, and added some echos to see what is actually getting compared.

#! /bin/bash

## Configuration Profiles
profileList=( "Chromium Edge" "Privacy Preferences Policy Control" "Security and Privacy" "Enterprise Connect" "System Restrictions" "Chrome Whitelist" "Network Configuration 2.0" "Chrome Extensions" "MAU_AppArray2019" "Approved Kernel Extensions" "Bomgar" "Office ProPlus 365" "ATP" "Chromium Edge Allowlist" "ScreenSaver Settings" "Disable Chrome Auto-Updates" "ShowDocStageOnLaunch" "MAU_AppArray" "MDM Profile" "macOSLAPS" "Browser Homepage" "Microsoft Auto Update Production""Office Preference Keys" )
missingProfiles=()

for i in "${profileList[@]}"; do
    checkProfile=$( profiles -C -v | awk -F: '/attribute: name/{print $NF}' | grep "$i" | sed -e 's/^[ \t]*//' )
    if [ ! "$checkProfile" == "$i" ]; then
        missingProfiles+=( "$i" );
        echo "i is $i"
        echo "checkProfile is $checkProfile"
    elif [ "$checkProfile" == "$i" ]; then
        echo "found $i"
        echo "found $checkProfile"
    fi
done

The output of this is:

found ScreenSaver Settings
found ScreenSaver Settings
found Disable Chrome Auto-Updates
found Disable Chrome Auto-Updates
found Chrome Whitelist
found Chrome Whitelist
i is MAU_AppArray                                       <-- why is it trying to compare this
checkProfile is MAU_AppArray2019                        <-- with this which is not the same?
MAU_AppArray                                            <-- where did this come from???
found MDM Profile
found MDM Profile
found ShowDocStageOnLaunch
found ShowDocStageOnLaunch
found macOSLAPS
found macOSLAPS
found Microsoft Auto Update Production
found Microsoft Auto Update Production
found Office Preference Keys
found Office Preference Keys
found ATP
found ATP
found Approved Kernel Extensions
found Approved Kernel Extensions
i is Chromium Edge                                      <-- "Chromium Edge" doesn't match
checkProfile is Chromium Edge                           <-- "Chromium Edge"????? huh?!
Chromium Edge Allowlist                                 <-- Again, unexpected...
found Privacy Preferences Policy Control
found Privacy Preferences Policy Control
found Security and Privacy
found Security and Privacy
found Enterprise Connect
found Enterprise Connect
found Browser Homepage
found Browser Homepage
found System Restrictions
found System Restrictions
found Network Configuration 2.0
found Network Configuration 2.0
found Chrome Extensions
found Chrome Extensions
found MAU_AppArray2019
found MAU_AppArray2019
found Office ProPlus 365
found Office ProPlus 365
found Chromium Edge Allowlist
found Chromium Edge Allowlist
found Bomgar
found Bomgar

I am so close... I am hoping someone here can take a look and spot whatever it is I have gotten wrong that is causing this.

EDIT

Adding the output of profiles -C -v | grep 'attribute:' as requested

_computerlevel[1] attribute: name: Chrome Whitelist
_computerlevel[1] attribute: configurationDescription: 
_computerlevel[1] attribute: installationDate: 2019-11-27 16:57:40 +0000
_computerlevel[1] attribute: organization: CompanyName Worldwide
_computerlevel[1] attribute: profileIdentifier: F3A66CB9-6847-4886-BAEF-D7577AEB816B
_computerlevel[1] attribute: profileUUID: F3A66CB9-6847-4886-BAEF-D7577AEB816B
_computerlevel[1] attribute: profileType: Configuration
_computerlevel[1] attribute: removalDisallowed: TRUE
_computerlevel[1] attribute: version: 1
_computerlevel[1] attribute: containsComputerItems: TRUE
_computerlevel[1] attribute: internaldata: TRUE
_computerlevel[2] attribute: name: Network Configuration 2.0
_computerlevel[2] attribute: configurationDescription: 
_computerlevel[2] attribute: installationDate: 2019-11-27 06:23:15 +0000
_computerlevel[2] attribute: organization: CompanyName Worldwide
_computerlevel[2] attribute: profileIdentifier: 524A33F3-6E6D-4A71-8404-E51D605BBF80
_computerlevel[2] attribute: profileUUID: 524A33F3-6E6D-4A71-8404-E51D605BBF80
_computerlevel[2] attribute: profileType: Configuration
_computerlevel[2] attribute: removalDisallowed: TRUE
_computerlevel[2] attribute: version: 1
_computerlevel[2] attribute: containsComputerItems: TRUE
_computerlevel[2] attribute: internaldata: TRUE
_computerlevel[3] attribute: name: Chrome Extensions
_computerlevel[3] attribute: configurationDescription: 
_computerlevel[3] attribute: installationDate: 2020-02-12 16:33:47 +0000
_computerlevel[3] attribute: organization: CompanyName Worldwide
_computerlevel[3] attribute: profileIdentifier: 7A2F528D-D5FD-4928-A70D-0B0FC9A91298
_computerlevel[3] attribute: profileUUID: 7A2F528D-D5FD-4928-A70D-0B0FC9A91298
_computerlevel[3] attribute: profileType: Configuration
_computerlevel[3] attribute: removalDisallowed: TRUE
_computerlevel[3] attribute: version: 1
_computerlevel[3] attribute: containsComputerItems: TRUE
_computerlevel[3] attribute: internaldata: TRUE
_computerlevel[4] attribute: name: MAU_AppArray2019
_computerlevel[4] attribute: configurationDescription: AppArray.plist registers the Office apps with MAU so they will be recognized and updated if never launched
_computerlevel[4] attribute: installationDate: 2020-03-06 15:16:14 +0000
_computerlevel[4] attribute: organization: CompanyName Worldwide
_computerlevel[4] attribute: profileIdentifier: 4577E363-29A6-45D2-BF8F-79008DA49D13
_computerlevel[4] attribute: profileUUID: 4577E363-29A6-45D2-BF8F-79008DA49D13
_computerlevel[4] attribute: profileType: Configuration
_computerlevel[4] attribute: removalDisallowed: TRUE
_computerlevel[4] attribute: version: 1
_computerlevel[4] attribute: containsComputerItems: TRUE
_computerlevel[4] attribute: internaldata: TRUE
_computerlevel[5] attribute: name: Approved Kernel Extensions
_computerlevel[5] attribute: configurationDescription: 
_computerlevel[5] attribute: installationDate: 2020-04-09 12:54:37 +0000
_computerlevel[5] attribute: organization: CompanyName Worldwide
_computerlevel[5] attribute: profileIdentifier: 9B96370D-BDD1-418E-B1DC-17DE0529F11D
_computerlevel[5] attribute: profileUUID: 9B96370D-BDD1-418E-B1DC-17DE0529F11D
_computerlevel[5] attribute: profileType: Configuration
_computerlevel[5] attribute: removalDisallowed: TRUE
_computerlevel[5] attribute: version: 1
_computerlevel[5] attribute: containsComputerItems: TRUE
_computerlevel[5] attribute: internaldata: TRUE
_computerlevel[6] attribute: name: Bomgar
_computerlevel[6] attribute: configurationDescription: 
_computerlevel[6] attribute: installationDate: 2020-02-18 18:38:46 +0000
_computerlevel[6] attribute: organization: CompanyName Worldwide
_computerlevel[6] attribute: profileIdentifier: 73ddbf1a-4f1e-48b9-bd24-69f8dc420aaa
_computerlevel[6] attribute: profileUUID: 73ddbf1a-4f1e-48b9-bd24-69f8dc420aaa
_computerlevel[6] attribute: profileType: com.apple.TCC.configuration-profile-policy
_computerlevel[6] attribute: removalDisallowed: TRUE
_computerlevel[6] attribute: version: 1
_computerlevel[6] attribute: containsComputerItems: TRUE
_computerlevel[6] attribute: internaldata: TRUE
_computerlevel[7] attribute: name: Office ProPlus 365
_computerlevel[7] attribute: configurationDescription: 
_computerlevel[7] attribute: installationDate: 2019-11-27 16:57:47 +0000
_computerlevel[7] attribute: organization: CompanyName Worldwide
_computerlevel[7] attribute: profileIdentifier: CDEB0EFC-453B-4918-8923-4B21F792F00D
_computerlevel[7] attribute: profileUUID: CDEB0EFC-453B-4918-8923-4B21F792F00D
_computerlevel[7] attribute: profileType: Configuration
_computerlevel[7] attribute: removalDisallowed: TRUE
_computerlevel[7] attribute: version: 1
_computerlevel[7] attribute: containsComputerItems: TRUE
_computerlevel[7] attribute: internaldata: TRUE
_computerlevel[8] attribute: name: ATP
_computerlevel[8] attribute: configurationDescription: 
_computerlevel[8] attribute: installationDate: 2020-03-16 13:43:15 +0000
_computerlevel[8] attribute: organization: CompanyName Worldwide
_computerlevel[8] attribute: profileIdentifier: FA6F8249-AACA-4EF9-912F-56DD498EB429
_computerlevel[8] attribute: profileUUID: FA6F8249-AACA-4EF9-912F-56DD498EB429
_computerlevel[8] attribute: profileType: Configuration
_computerlevel[8] attribute: removalDisallowed: TRUE
_computerlevel[8] attribute: version: 1
_computerlevel[8] attribute: containsComputerItems: TRUE
_computerlevel[8] attribute: internaldata: TRUE
_computerlevel[9] attribute: name: Chromium Edge Allowlist
_computerlevel[9] attribute: configurationDescription: 
_computerlevel[9] attribute: installationDate: 2020-03-16 16:09:28 +0000
_computerlevel[9] attribute: organization: CompanyName Worldwide
_computerlevel[9] attribute: profileIdentifier: F2B92C2D-69CC-4C15-AE52-F5986AD49D21
_computerlevel[9] attribute: profileUUID: F2B92C2D-69CC-4C15-AE52-F5986AD49D21
_computerlevel[9] attribute: profileType: Configuration
_computerlevel[9] attribute: removalDisallowed: TRUE
_computerlevel[9] attribute: version: 1
_computerlevel[9] attribute: containsComputerItems: TRUE
_computerlevel[9] attribute: internaldata: TRUE
_computerlevel[10] attribute: name: ScreenSaver Settings
_computerlevel[10] attribute: configurationDescription: 
_computerlevel[10] attribute: installationDate: 2019-11-27 16:57:49 +0000
_computerlevel[10] attribute: organization: CompanyName Worldwide
_computerlevel[10] attribute: profileIdentifier: 94536F86-3AAD-4F4B-87F9-CE338543F53F
_computerlevel[10] attribute: profileUUID: 94536F86-3AAD-4F4B-87F9-CE338543F53F
_computerlevel[10] attribute: profileType: Configuration
_computerlevel[10] attribute: removalDisallowed: TRUE
_computerlevel[10] attribute: version: 1
_computerlevel[10] attribute: containsComputerItems: TRUE
_computerlevel[10] attribute: internaldata: TRUE
_computerlevel[11] attribute: name: Disable Chrome Auto-Updates
_computerlevel[11] attribute: configurationDescription: 
_computerlevel[11] attribute: installationDate: 2019-11-27 16:57:46 +0000
_computerlevel[11] attribute: organization: CompanyName Worldwide
_computerlevel[11] attribute: profileIdentifier: F23C4E5B-F91F-4917-A6B3-DA77E7883A38
_computerlevel[11] attribute: profileUUID: F23C4E5B-F91F-4917-A6B3-DA77E7883A38
_computerlevel[11] attribute: profileType: Configuration
_computerlevel[11] attribute: removalDisallowed: TRUE
_computerlevel[11] attribute: version: 1
_computerlevel[11] attribute: containsComputerItems: TRUE
_computerlevel[11] attribute: internaldata: TRUE
_computerlevel[12] attribute: name: ShowDocStageOnLaunch
_computerlevel[12] attribute: configurationDescription: suppress design galleries for all Office products (PowerPoint, Word, Excel)
_computerlevel[12] attribute: installationDate: 2020-02-18 16:25:13 +0000
_computerlevel[12] attribute: organization: CompanyName Worldwide
_computerlevel[12] attribute: profileIdentifier: D9F5A6EF-0CDB-4FD8-9476-D3797CE09F1A
_computerlevel[12] attribute: profileUUID: D9F5A6EF-0CDB-4FD8-9476-D3797CE09F1A
_computerlevel[12] attribute: profileType: Configuration
_computerlevel[12] attribute: removalDisallowed: TRUE
_computerlevel[12] attribute: version: 1
_computerlevel[12] attribute: containsComputerItems: TRUE
_computerlevel[12] attribute: internaldata: TRUE
_computerlevel[13] attribute: name: MAU_AppArray
_computerlevel[13] attribute: configurationDescription: AppArray.plist registers the Office apps with MAU so they will be recognized and updated if never launched
_computerlevel[13] attribute: installationDate: 2019-11-27 16:57:39 +0000
_computerlevel[13] attribute: organization: CompanyName Worldwide
_computerlevel[13] attribute: profileIdentifier: F5C37198-E0F5-419F-9CDA-4E25168B5B52
_computerlevel[13] attribute: profileUUID: F5C37198-E0F5-419F-9CDA-4E25168B5B52
_computerlevel[13] attribute: profileType: Configuration
_computerlevel[13] attribute: removalDisallowed: TRUE
_computerlevel[13] attribute: version: 1
_computerlevel[13] attribute: containsComputerItems: TRUE
_computerlevel[13] attribute: internaldata: TRUE
_computerlevel[14] attribute: name: MDM Profile
_computerlevel[14] attribute: configurationDescription: MDM Profile for mobile device management
_computerlevel[14] attribute: installationDate: 2019-11-27 16:57:05 +0000
_computerlevel[14] attribute: organization: CompanyName Worldwide
_computerlevel[14] attribute: profileIdentifier: 00000000-0000-0000-A000-4A414D460003
_computerlevel[14] attribute: profileUUID: 00000000-0000-0000-A000-4A414D460003
_computerlevel[14] attribute: profileType: Configuration
_computerlevel[14] attribute: removalDisallowed: FALSE
_computerlevel[14] attribute: version: 1
_computerlevel[14] attribute: containsComputerItems: TRUE
_computerlevel[14] attribute: internaldata: TRUE
_computerlevel[15] attribute: name: macOSLAPS
_computerlevel[15] attribute: configurationDescription: 
_computerlevel[15] attribute: installationDate: 2019-11-27 16:57:48 +0000
_computerlevel[15] attribute: organization: CompanyName Worldwide
_computerlevel[15] attribute: profileIdentifier: A39A88CD-E2AE-4C20-A4E6-78807E066EA6
_computerlevel[15] attribute: profileUUID: A39A88CD-E2AE-4C20-A4E6-78807E066EA6
_computerlevel[15] attribute: profileType: Configuration
_computerlevel[15] attribute: removalDisallowed: TRUE
_computerlevel[15] attribute: version: 1
_computerlevel[15] attribute: containsComputerItems: TRUE
_computerlevel[15] attribute: internaldata: TRUE
_computerlevel[16] attribute: name: Browser Homepage
_computerlevel[16] attribute: configurationDescription: 
_computerlevel[16] attribute: installationDate: 2019-11-27 16:57:48 +0000
_computerlevel[16] attribute: organization: CompanyName Worldwide
_computerlevel[16] attribute: profileIdentifier: 0BB2B3A8-3F25-4C98-AB55-10E0DCD17C60
_computerlevel[16] attribute: profileUUID: 0BB2B3A8-3F25-4C98-AB55-10E0DCD17C60
_computerlevel[16] attribute: profileType: Configuration
_computerlevel[16] attribute: removalDisallowed: TRUE
_computerlevel[16] attribute: version: 1
_computerlevel[16] attribute: containsComputerItems: TRUE
_computerlevel[16] attribute: internaldata: TRUE
_computerlevel[17] attribute: name: Microsoft Auto Update Production
_computerlevel[17] attribute: configurationDescription: 
_computerlevel[17] attribute: installationDate: 2020-04-20 13:29:20 +0000
_computerlevel[17] attribute: organization: CompanyName Worldwide
_computerlevel[17] attribute: profileIdentifier: 9187EFD8-7FCF-4848-942A-F7E06BBF08CF
_computerlevel[17] attribute: profileUUID: 9187EFD8-7FCF-4848-942A-F7E06BBF08CF
_computerlevel[17] attribute: profileType: Configuration
_computerlevel[17] attribute: removalDisallowed: TRUE
_computerlevel[17] attribute: version: 1
_computerlevel[17] attribute: containsComputerItems: TRUE
_computerlevel[17] attribute: internaldata: TRUE
_computerlevel[18] attribute: name: Office Preference Keys
_computerlevel[18] attribute: configurationDescription: 
_computerlevel[18] attribute: installationDate: 2019-11-27 16:58:01 +0000
_computerlevel[18] attribute: organization: CompanyName Worldwide
_computerlevel[18] attribute: profileIdentifier: D369D410-0E42-44CD-BBA5-C972C3873A67
_computerlevel[18] attribute: profileUUID: D369D410-0E42-44CD-BBA5-C972C3873A67
_computerlevel[18] attribute: profileType: Configuration
_computerlevel[18] attribute: removalDisallowed: TRUE
_computerlevel[18] attribute: version: 1
_computerlevel[18] attribute: containsComputerItems: TRUE
_computerlevel[18] attribute: internaldata: TRUE
_computerlevel[19] attribute: name: Chromium Edge
_computerlevel[19] attribute: configurationDescription: 
_computerlevel[19] attribute: installationDate: 2020-03-16 16:09:27 +0000
_computerlevel[19] attribute: organization: CompanyName Worldwide
_computerlevel[19] attribute: profileIdentifier: 181BC800-F3E4-4760-BA33-515C938B5D6D
_computerlevel[19] attribute: profileUUID: 181BC800-F3E4-4760-BA33-515C938B5D6D
_computerlevel[19] attribute: profileType: Configuration
_computerlevel[19] attribute: removalDisallowed: TRUE
_computerlevel[19] attribute: version: 1
_computerlevel[19] attribute: containsComputerItems: TRUE
_computerlevel[19] attribute: internaldata: TRUE
_computerlevel[20] attribute: name: Privacy Preferences Policy Control
_computerlevel[20] attribute: configurationDescription: Profile for Jamf management framework
_computerlevel[20] attribute: installationDate: 2019-11-27 16:58:03 +0000
_computerlevel[20] attribute: organization: Jamf Software
_computerlevel[20] attribute: profileIdentifier: com.jamfsoftware.tcc.management
_computerlevel[20] attribute: profileUUID: com.jamfsoftware.tcc.management
_computerlevel[20] attribute: profileType: Configuration
_computerlevel[20] attribute: removalDisallowed: TRUE
_computerlevel[20] attribute: version: 1
_computerlevel[20] attribute: containsComputerItems: TRUE
_computerlevel[20] attribute: internaldata: TRUE
_computerlevel[21] attribute: name: Security and Privacy
_computerlevel[21] attribute: configurationDescription: 
_computerlevel[21] attribute: installationDate: 2019-11-27 16:57:41 +0000
_computerlevel[21] attribute: organization: CompanyName Worldwide
_computerlevel[21] attribute: profileIdentifier: A3AD439A-5E19-4A62-BC3A-F1820865D3A9
_computerlevel[21] attribute: profileUUID: A3AD439A-5E19-4A62-BC3A-F1820865D3A9
_computerlevel[21] attribute: profileType: Configuration
_computerlevel[21] attribute: removalDisallowed: TRUE
_computerlevel[21] attribute: version: 1
_computerlevel[21] attribute: containsComputerItems: TRUE
_computerlevel[21] attribute: internaldata: TRUE
_computerlevel[22] attribute: name: Enterprise Connect
_computerlevel[22] attribute: configurationDescription: 
_computerlevel[22] attribute: installationDate: 2019-11-27 16:57:38 +0000
_computerlevel[22] attribute: organization: CompanyName Worldwide
_computerlevel[22] attribute: profileIdentifier: 50273D5A-D5A8-489D-8909-AD9B1F79B9E7
_computerlevel[22] attribute: profileUUID: 50273D5A-D5A8-489D-8909-AD9B1F79B9E7
_computerlevel[22] attribute: profileType: Configuration
_computerlevel[22] attribute: removalDisallowed: TRUE
_computerlevel[22] attribute: version: 1
_computerlevel[22] attribute: containsComputerItems: TRUE
_computerlevel[22] attribute: internaldata: TRUE
_computerlevel[23] attribute: name: System Restrictions
_computerlevel[23] attribute: configurationDescription: Disables System Preferences options.
_computerlevel[23] attribute: installationDate: 2020-04-02 14:04:43 +0000
_computerlevel[23] attribute: organization: CompanyName Worldwide
_computerlevel[23] attribute: profileIdentifier: 35EA461C-9D98-40FA-A3E0-4CC297C9D601
_computerlevel[23] attribute: profileUUID: 35EA461C-9D98-40FA-A3E0-4CC297C9D601
_computerlevel[23] attribute: profileType: Configuration
_computerlevel[23] attribute: removalDisallowed: TRUE
_computerlevel[23] attribute: version: 1
_computerlevel[23] attribute: containsComputerItems: TRUE
_computerlevel[23] attribute: internaldata: TRUE
_computerlevel[24] attribute: name: CompanyName Email Signature Creator
_computerlevel[24] attribute: configurationDescription: 
_computerlevel[24] attribute: installationDate: 2019-11-27 16:57:52 +0000
_computerlevel[24] attribute: organization: CompanyName Worldwide
_computerlevel[24] attribute: profileIdentifier: 1da8b849-729a-4bb2-9fee-08886205a19b
_computerlevel[24] attribute: profileUUID: 1da8b849-729a-4bb2-9fee-08886205a19b
_computerlevel[24] attribute: profileType: com.apple.TCC.configuration-profile-policy
_computerlevel[24] attribute: removalDisallowed: TRUE
_computerlevel[24] attribute: version: 1
_computerlevel[24] attribute: containsComputerItems: TRUE
_computerlevel[24] attribute: internaldata: TRUE
  • Can you add the complete output of `profiles -C -v`, or maybe just the output of `profiles -C -v | grep 'attribute:'` – Luuk Apr 25 '20 at 13:09
  • Edited to add as it is much too long for a comment. – ronin.andrew Apr 27 '20 at 18:35
  • I think your have to trim `$NF`, like this: `gsub(/^ +| +$/,"",$NF); print $NF` (see: https://stackoverflow.com/questions/9985528/how-can-i-trim-white-space-from-a-variable-in-awk) – Luuk Apr 28 '20 at 16:43
  • I tried changing the line checkProfile=$( profiles -C -v | awk -F: '/attribute: name/{print $NF}' | grep "$i" | sed -e 's/^[ \t]*//' ) to checkProfile=$( profiles -C -v | awk -F: '/attribute: name/{gsub(/^ +| +$/,"",$NF); print $NF}' | grep "$i" | sed -e 's/^[ \t]*//' ) and see no change. I am in way over my head with syntax here for all the trimming and filtering stuff. – ronin.andrew Apr 28 '20 at 20:17
  • While some thing might be done 'cleaner' than this solution, i am out of options right now. Hopefully someone else can share thoughts. – Luuk Apr 30 '20 at 05:34

1 Answers1

1

I did have a look at your script, and re-wrote it to this:

#! /bin/bash

## Configuration Profiles
profileList=( "Chromium Edge" "Privacy Preferences Policy Control" "Security and Privacy" "Enterprise Connect" "System Restrictions" "Chrome Whitelist" "Network Configuration 2.0" "Chrome Extensions" "MAU_AppArray2019" "Approved Kernel Extensions" "Bomgar" "Office ProPlus 365" "ATP" "Chromium Edge Allowlist" "ScreenSaver Settings" "Disable Chrome Auto-Updates" "ShowDocStageOnLaunch" "MAU_AppArray" "MDM Profile" "macOSLAPS" "Browser Homepage" "Microsoft Auto Update Production" "Office Preference Keys" )
missingProfiles=()

tmpfile=/tmp/$$.tmp
profiles -C -v | awk -F: '/attribute: name/{ gsub(/^ | +$/,"",$NF); print $NF}' > $tmpfile

for i in "${profileList[@]}"; do
    echo -n Checking profile: "$i"
    c=$( grep -c "$i" $tmpfile )
    if [ $c -gt 0 ];
    then
        echo " FOUND"
    else
        echo " NOT FOUND"
        missingProfiles+=( "$i" );
    fi
done
echo MISSINGPROFILES: $missingProfiles

This script will first collect the 'profile names' in a tempfile

And then check (grep -c) how many times the profile from $profilesList is in this tmpfile.

There is a temporary file created, and i am currently not deleting it, but if you want you can add rm $tmpfile at the end of this script.

Luuk
  • 12,245
  • 5
  • 22
  • 33
  • I tested this a bit more carefully by changing some of the control item names in profileList and nothing fails as expected. – ronin.andrew May 04 '20 at 19:12
  • More testing... it is working. I am confused why I saw unexpected behavior, but happy this seems to be working. I don't care if it is clean or not, I just need something consistent. – ronin.andrew May 04 '20 at 19:57