Video tutorial on how to replace the brake light switch under the dash on a BMW E39. This particular video was done on a 1997 BMW 540i. If your brake lights aren't working, this could be the culprit of the issue.

Procedure:
-start by removing the carpet piece on the center console towards the underneath of the using removing 1 phillips screw, then sliding the trim piece towards the rear of the vehicle
-next move onto the plastic pan on the underside of the dash on the driver's side of the vehicle
-the plastic pan is held in with twist clips towards the front by the pedals and phillips screws towards the dash side
-once removed, you now have 2 plugs to disconnect from the chime speak (squeeze the plug tabs and pull straight out)
-remove the electrical connector from the backside of the switch just pulls straight out
-locate the brake pedal switch (do not get it confused with the clutch switch if applicable)
-the easiest way I found to remove the switch was to brake off the plunger on the front side rather than sliding the sleeve all the way forward
-now it is easier to slide the red sleeve forward and pull the switch out of the bracket
-in order to reinstall the new switch, you must pull the red sleeve out enough so the tabs are able to collapse (the white plunger can also be pulled out)
-pushing on the brake pedal, reinstall the new switch, then push the red sleeve back in
-let the pedal back and reinstall the electrical connector
-make sure the brake lights are working
-trim installation in reverse