Most of the time the cable goes bad from the sunroof shackle to the motor. This is a pretty simple ordeal . You have to get the sunroof far enough back to remove liner. Its just clips in the front but be careful not to bend the headliner. after removal of the liner you can disconnect the cable from the shackle. Then run the sunroof in the forward position and remove the cable. Look at it and see if it is bound up and not straight. If not then slide the sunroof forward and backward by hand if it moves freely well I would replace the motor if the cable is not bad .if the cable is bad make sure you get a new clip and inspect shackle for any wear.
Good luck