There are several ways to do this.
One of the easiests ways is to use the
hypershade -assign [materialName]
command. I have never been a fan of this because this command requires you to select a surface to apply the material and it is an abstraction of what is really going on. The script window shows that executing this command actually executes...
sets -e -forceElement [materialName]
Approaching it from this direction gives you more understanding of how Maya handles material assignment. Basically, a material assignment is nothing more than a set. The set contains all objects or faces with that material. Adding something to that set applies the material to it. Using the sets command for material assignment gives you a lot more power for assigning and querying materials. It also reminds that you that you can use the set editor to look at membership of material sets.
--JeffD