Most of my limited knowledge of TMS mainly focuses on the research side of it, not the treatment side of it. Anyway, here's some stuff I have about it from my textbook and notes.
During Transcranial Magnetic Stimulation, they essentially stimulate certain parts of the brain using a wand made of electrical capacitors that are connected to a tightly coiled wire encased in an insulated sheath. It basically generates a magnetic field that is able to penetrate through the skull and alter the electrical activity of neurons located along the cortical surface. Depending on where they position the wand they can do things, such as cause you to have trouble with processing visual motion/akinetopsia (which would happen if it moved over V5, which is located on the occipital lobe) or cause you to move your hands involuntarily (would happen if the coil was over the hand area part of the motor cortex).
The effects of the stimulation may either inhibit or enhance neural activity. It can also be used to essentially induce "virtual lesions" by disrupting normal activity in select regions of the brain. It is great since, like lesion studies, it can allow researchers to study the brain and how local parts of it play a role in certain functions but without having to do invasive procedures to produce actual lesions.
There are many ways in which stimulation can be manipulated (protocols), such as administering TMS pulses at varying intensities, frequencies, and timings (single, repetitive, continuous). There is also doing it "online", meaning that the participant is doing a task while having it performed on them, or "offline", in which the effects of TMS may last beyond the duration of the stimulus itself.
It's generally pretty safe (though it isn't generally recommended if you have epilepsy or a history of seizures). I don't know much about it in regards to the treatment and management of mental illnesses though. I know that repetitive TMS (rTMS) is sometimes used for treating treatment-resistant depression (like in your case) and there have been looks into using it to treat hallucinations and neurological diseases.
Here's some stuff about it in regards to the treatment of depression.