I experienced the same problem with the engine shaking a few weeks ago. My car is a 328xi it has 55600 miles and started to shake the morning before going to work. I took it to get a diagnostic at the dealer which was $125. It turns out that there was a misfire somewhere in the engine (u can get a reading with a OBD2tool). One or two of the ignition coils or spark plugs was not working which made it run like a 4 or 5 cylinder engine instead of all 6 firing.
So instead of going to the dealer to get it fixed, I just bought the parts myself and worked on replacing the ignition coils and spark plugs myself. I bought 6 bosch Ignition coils (www.fcpeuro.com
) oem seller and 6 iridium NGK spark plugs (amazon).
After replacing the coils and plugs I started up the engine with the OBD2 scanner connected and tested out the difference. I noticed the same shaking. So I went back and tightened every ignition coil and checked my OBD2 for a reading. The OBD scanned no misfires after tightening the coils. After a few tests it went back to the smooth engine startup.
If you DIY make sure you have the proper tools. The cable housing underneath the cabin air filter might be a pain to deal with.
I hope this helps, let me know if the problem is something else. I would like to learn how to troubleshoot if its not the ignition coils or plugs.