MaxScript to batch render with automatic material loop changes

Hi!

I have a scene with a single Sphere, and I need to render and save pictures of this scene several times with each material, (as many materials as i have in the material editor).

So basically I need a script to automatically change the material of the spehere, then render the scene save the image file, and repeat for all the materials.

Is it possible to write such a script?

Thanks in advance :)