I tried making something myself and it works successfully on El Capitan 10.11.6 with Bartender 2. Should work on any Mac (with or without Bartender) as long as Apple doesn't change the Notification Center plist location (I think...).
I got the code from this StackOverflow answer and converted it into a simple Alfred workflow. Here it is if you want to give it a try
PS. It doesn't need to have Accessibility enabled which is a nice bonus.