Can I prevent an eviction by filing for Bankruptcy? Yes
If you file for bankruptcy BEFORE your landlord has a Judgment For Possession, the Automatic Stay triggers protection from an unwanted eviction. At this point, your landlord would be required to file a Motion to Lift Stay in order to proceed with the eviction in Michigan Courts.
If you file for bankruptcy AFTER your landlord has a Judgment For Possession, the Automatic Stay will not automatically give you protection from an unwanted eviction. To get this protection you would need to make a deposit with the court in an amount sufficient to cure the default.
The rules above only apply in situations where a landlord is trying to evict you from a residential property. If you are (1) being evicted from you home by your lender, post foreclosure, or (2) being evicted from a commercial property, then it does not matter whether or not a Judgment For Possession exists, the party attempting to evict you would need to lift the automatic stay before they are able to proceed with any action.