According to Chris Morley, it’s sometimes possible to get Y-DNA results from an autosomal test:
“Some autosomal genetic genealogy tests (such as 23andMe, AncestryDNA and MyHeritage – but not Family Finder) also contain a few hundred Y-DNA markers. The Y-DNA data from these tests is of lower quality, but may still suffice for a very, very general Y-DNA haplogroup classification.
“This is useful if you need to make a very basic Y-DNA comparison between two men: if for instance one man is R1b and the other man is I1, then you can be certain their patrilineal connection is not genealogically significant. If both men have the same high-level classification then they will need further Y-DNA testing to confirm a recent patrilineal connection.”
I’ve never tried it, but if you’re interested you can find more information at Morleyydna.com. Steven Frank has also written about it: Updated Method to get YDNA haplogroup from AncestryDNA results (Aug. 10, 2017).