Remove Duplicate Certificates in Login Keychain

New Contributor

I am finding several instances in our environment where a user has duplicate certificates matching their username in their login keychain. Any suggestions for ways to script removing certificates in a group of user's login keychain that match the respective logged in user's username?

The useful script shared by @Gonzalo here (at the very bottom on 2/15/21) enabled us to remove all certs in the system keychain that matched the machine's hostname...hoping that the same is possible by username and within their login keychain...