These things get to be called doing a mitzvah in the context of the cult that the Gra signed the excommunication on
To gain mystic powers would seem to be just what Bilaam was about. He was open to God but also open to the Sitra Achra (Dark Side).
The way this is made to be kosher is by a slight of hand. They do not call it כישוף but rather "תיקונים" But the idea is the same. Instead of doing God's will in the Law it is to gain spiritual powers.
And often it works. People would not be having shamans and rituals of this nature for thousands of years if there was not some effect.