If the spell is not countered (because the spell it targets can’t be countered), then it does not get exiled but all the other copies in the graveyard, hand, and library are exiled.

Artwork
Loading artwork…
Quash
Betrayers of Kamigawa · #47 · EN
Nonfoil—Foil—
Card rules
Counter target instant or sorcery spell. Search its controller's graveyard, hand, and library for all cards with the same name as that spell and exile them. Then that player shuffles.
Uncommon · Illustrated by Shishizaru
Format legality
Commander Legal
Duel Legal
Legacy Legal
Modern Legal
Oathbreaker Legal
Penny Legal
PreDH Legal
Premodern Legal
Vintage Legal
Alchemy Not Legal
Brawl Not Legal
Competitive Brawl Not Legal
Future Not Legal
Gladiator Not Legal
Historic Not Legal
Old School Not Legal
Pauper Not Legal
Pauper Commander Not Legal
Pioneer Not Legal
Standard Not Legal
Standard Brawl Not Legal
Timeless Not Legal
Tlr Not Legal
Rulings
Published rulings from the downloaded Scryfall catalog. Source card record · Rules and interactions
It exiles the countered spell. This is because the first sentence puts the spell into the graveyard before you continue to the second sentence.
Quash can exile cards even if the spell countered was a copy of a spell. For example, if you Quash a Boomerang cast from an Isochron Scepter, you may search for and exile cards named Boomerang.
If Quash counters a spell that has had text spliced onto it, only the base spell may be exiled. For example, if you use Quash to counter a Kodama’s Might with a Glacial Ray spliced onto it, you may search for and exile only Kodama’s Might.
The copies must be found if they are in publicly viewable zones. Finding copies while searching private zones is optional.