The order comes at the request of the British Phonographic Association (BPI), a music industry trade association.
The court action gives the ISPs 14 days to reveal the song-swappers' details, including names and addresses, so the trade association can start to take action against them.
Initially, BPI said, it will write to the 28, setting out how they have allegedly contravened copyright law and offer them the chance to settle out of court.
In approving the order, the judge said: "On the face of it this appears to be a powerful case of copyright infringement."
A representative for the Internet Service Providers Association said he expects that the 14-day deadline will be met. "I don't know anyone who is looking to challenge it... I don't know any ISP who is up in arms about this" he said.
He added, however, that the court order was necessary because ISPs can't give out customers' details "willy nilly" and legal processes must be followed.
BPI also announced that it has taken action against download site Jetgroove.com. The site had posted 50,000 songs without the permission of the copyright holders but asserted that it would pay royalties on the songs.
Following a cease-and-desist order from BPI and the International Federation of the Phonographic Industry, the tracks have been removed. The two bodies will continue to monitor the site. Jo Best of Silicon.com reported from London.