I actually have tested this in the past!
When a Pokémon with Moxie causes another Pokémon (including allies) to faint through direct damage, its Attack rises by one stage. Moxie will not be activated by indirect damage, such as through Sandstorm or an ability like Rough Skin. Moxie will not activate if an allied Pokémon defeats a foe in a double or triple battle. If a Pokémon with Moxie defeats a Pokémon with Mummy using a physical move, the Pokémon's ability will turn to Mummy before the attack boost is given. - Bulbapedia
So Yes, if he knocked out even an Ally, he would get his Attack boost, Neat isn't it?