2 year old trying to hurt newborn

My almost two year won’t stop trying to hit my newborn. He even tries to poke her in the eye, lay on her, and tries to throw things at her. It’s driving me crazy. I give him a lot of good attention whenever he interacts with her nicely which is rare. What can I do to make him understand why he can’t hit her or throw things at her?