Grounded (Star Trek: The Next Generation #25) by David Bischoff
While answering a distress call from a scientific station in a remote part of the galaxy, the U.S.S. Enterprise becomes infected with a mysterious alien life form which feeds on and transforms inorganic materials.
The Starship begins to gradually disintegrate, and Starfleet is forced to order its evacuation and destruction to prevent the dangerous infection from spreading throughout the galaxy. It's the end of an era for Captain Picard and his crew, who are scheduled for transfers that will split them up among different Starfleet vessels.
But even as the end draws near for the Starship Enterprise, Captain Picard begins to formulate a desperate plan to save his ship and preserve his crew—a plan that will force him to defy Starfleet orders and lead him to a confrontation with a malevolent alien force which has the power to destroy the entire Federation.