How can I set the material on an instance after creating it?

I have a cuboid prefab and want to dynamically set the texture applied to it after instancing it. How do I set the material?

Have you seen this thread?