Re-installing a 802.1x configuration profile

yurypanasyuk
New Contributor III

Hello,

I am looking for help on re-installing a single wifi config profile using bash. This is what I have currently. It works fine but at the beginning I get this prompt, "Enter the profile removal password:". I just press 'Enter' since there is no password. Anyway of bypassing this or a way to script in the 'Enter' key ('expect' command possibly?) Ive tried re-installing the config profile by profile identifier and from the profile file. Same outcome. =/

#!/bin/bash

WIFI_PROFILES=$(sudo /usr/bin/profiles -P | grep -c 'WiFiv4')
GMID=$(sudo /usr/bin/profiles -Lv | awk '/attribute: name: / && /WiFiv4/,/attribute: profileIdentifier:/' | awk '/attribute: profileIdentifier:/ {print $4}')

if [[ $WIFI_PROFILES == "1" ]]; then
sudo profiles -R -p $GMID
sudo profiles -I -F /Library/Security/configuration_profiles/WiFiv4.mobileconfig
fi
6 REPLIES 6

alexjdale
Valued Contributor III

Does the profile have a null password entry? Is " PayloadRemovalDisallowed" set to true? I can't think of any reason why it would need a password. You could try passing it "" as a password with the -z option.

mm2270
Legendary Contributor III

Yeah, like @alexjdale mentioned, unless there is a password for removal set or some other key in the config, it really shouldn't prompt for a password. I assume the script is being run as root or with sudo privs, right?
How was the profile installed by the way? From a script using a local .mobileconfig file, or was it pushed over MDM?

yurypanasyuk
New Contributor III

Im not an admin for JSS but im pretty sure the profiles are installed during our provisioning process. Installed from a folder not pushed over MDM. And yes running with sudo.

Still getting an error.

"profiles uninstall for identifier:'-z' and user:'root' returned -205 (Unable to locate configuration profile.)"

Command i changed: sudo /usr/bin/profiles -R -p -z "" $GMID

If i remove the -z flag then it prompts me for the password. Strange. =/

alexjdale
Valued Contributor III

You would need to put the -p right before the $GMID, you put the -z flag and password entries between them.

yurypanasyuk
New Contributor III

Still asks for removal password.

yurypanasyuk
New Contributor III

Figured it out! Instead of just doing double quotes for a blank password i put in random text and it just works! lol Not sure whats up but that does it.