Accepting Azure Marketplace terms in PowerShell

Marketplace terms… If you’ve ever deployed resources into Azure from the Marketplace at the point of deployment you’ll often see the screen shown below: You’re accepting the terms of use for the Marketplace offering for the subscription you’re currently working within. However if you try to deploy a resource from the Marketplace through a json template and you’ve not accepted the terms previously you’ll get an error like so: The error message is fairly self explanatory, Code=MarketplacePurchaseEligibilityFailed indicates you’re not eligible to deploy the resource and Legal terms have not been accepted for this item on this subscription make it clear what the issue is.