In December 2011 the company brought in a random testing programme, and in August 2012 Mr Cowell was randomly selected to undergo a test and refused.
He then privately took a drug test at his own expense, which was negative.
Mr Cowell said he declined the test because it was contrary to his collective agreement, which allowed the company to seek evidence of workers' fitness for work, but requests could only be made in writing, with reasonable just cause.
The court found Mr Cowell was entitled to refuse the test, and the company could not impose sanctions against him for refusing.
It found the collective agreement did not allow for random testing, and that the company could not collect workers' personal information without consent.
Mighty River Power had claimed that even if the employee was entitled to refuse testing, it was still entitled to investigate the reasons for the refusal, and impose sanctions including dismissal.
The court said an employer could not justify disciplining an employee for exercising their rights. It said the claim was "such a remarkable proposition that it is understandably difficult to find not only any authority to support it but, indeed, any judicial analysis of, and comment on, it."
The court found the company's drug policy was not enforceable in respect of employees covered by the collective agreement.
A new provision in the collective agreement would need to be negotiated. before a random testing regime could be introduced.