Echo the above comments and especially check your ground connection. In my E39 and E60 hardwires, I grounded to one of the screws on the sunroof motor.
Seems the green-brown wire in this area has consistently been the ticket for power over the model years, IIRC.....
I need to do this mod soon to get rid of dangling wires...
Former M cars: Euro E30 M3, 01 E39 M5, 08 E60 M5