But if it turns out to be a spell that you're restricted from, then you can't cast it. For example, if it says "Dark Mage Only" (like Drain Soul) and you're not a Dark Mage, then you can't cast that spell. You'll still have the wand, it'll just be a little useless. If the wand lets you switch out the attached spell, then the new spell will come from your spellbook, and the old spell will go back into its owner's spellbook where it came from originally.
This can all be found in the Supplement.