Posted on 06-04-2019 06:03 AM
We're still struggling to get our Macs to register with Intune. After each failed attempt, in addition to removing the partial computer entries from Intune, we have to delete every single file and keychain entry that has anything at all to do with Intune and the Company portal app. After a lot of searching I came up with this script to remove the files associated with it:
#!/bin/sh
#variable for storing the current users name assuming the computer has the end user
# and not the admin user logged in when this script is run.
currentuser=`stat -f "%Su" /dev/console`
rm -Rfv /Users/$currentuser/Library/Application Support/com.microsoft.CompanyPortal.usercontext.info
rm -Rfv /Users/$currentuser/Library/Application Support/com.microsoft.CompanyPortal
rm -Rfv /Users/$currentuser/Library/Application Support/com.jamfsoftware.selfservice.mac
rm -Rfv /Users/$currentuser/Library/Saved Application State/com.jamfsoftware.selfservice.mac.savedState
rm -Rfv /Users/$currentuser/Library/Saved Application State/com.microsoft.CompanyPortal.savedState
rm -Rfv /Users/$currentuser/Library/Preferences/com.microsoft.CompanyPortal.plist
rm -Rfv /Users/$currentuser/Library/Preferences/com.jamfsoftware.selfservice.mac.plist
rm -Rfv /Users/$currentuser/Library/Preferences/com.jamfsoftware.management.jamfAAD.plist
rm -Rfv /Users/$currentuser/Library/Cookies/com.microsoft.CompanyPortal.binarycookies
rm -Rfv /Users/$currentuser/Library/Cookes/com.jamf.management.jamfAAD.binarycookies
I am having a helluva time trying to figure out how to automate the removal of the keychain items. There are so many and I can't make heads or tails out of the security
command. So far I have found the following in the current user's Login keychain that seem to have anything to do with Intune:
I would prefer to use a surgical methodology to only remove the Intune-specific Keychain entries and leave the user's other keychain items untouched. I don't know where to begin. I've spent weeks trying to figure out how to use the security
command but I'm getting nowhere. Does anyone else have a way to automate this?
Solved! Go to Solution.
Posted on 06-04-2019 08:37 PM
I created a blog post on how to do this. Read Here
Posted on 06-04-2019 08:37 PM
I created a blog post on how to do this. Read Here
Posted on 08-16-2021 07:51 AM
I cant access your blog. Can you please that post also here?
jusst curious, am I the only one who cant access the website?
Posted on 06-05-2019 03:26 AM
hmmm interesting. I'll take a look at it.
Posted on 07-24-2019 04:46 AM
@kerickson I just discovered that the script causes Self Service to crash since upgrading to Mojave 10.14.6.
Posted on 07-24-2019 04:55 AM
The only other thing I've done was to upgrade from JamfPro 10.9.0 to 10.13.0, but I suspect Mojave 10.14.6 doesn't like some of the security commands.
In the log, after the part where it deletes the Application Support and Preference files it says this:
Remove keychain password items
security: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.
[message repeats 9 times]
delete-identity: option requires an argument -- Z
Usage: delete-identity [-c name] [-Z hash] [-t] [keychain...]
-c Specify certificate to delete by its common name
-Z Specify certificate to delete by its SHA-1 hash value
-t Also delete user trust settings for this identity certificate
The identity to be deleted must be uniquely specified either by a
string found in its common name, or by its SHA-1 hash.
If no keychains are specified to search, the default search list is used.
Delete an identity (certificate + private key) from a keychain.
Posted on 07-24-2019 05:15 AM
ya know... there's something else going on here... the log snippet I pasted above was not from the first crash. Sorry about that. I need to dig deeper.