title: How to delete all devices from Azure IoT Hub using Azure CLI?
body: <p>I have an Azure IoT Hub with a bunch of devices that our team's E2E tests generate. I want to purge the Hub every once in a while using the Azure CLI. </p>
  
  <p>I am running the Azure CLI locally on <strong>Powershell</strong>, using the <a href="https://github.com/Azure/azure-iot-cli-extension" rel="nofollow noreferrer">Azure IoT extension</a>.</p>
  
  <p>From my research, there is a way to get a list of all the devices in a hub printed to the console in JSON format:</p>
  
  <pre class="lang-bsh prettyprint-override"><code>az iot hub device-identity list --hub-name "test-hub"
  </code></pre>
  
  <p>And there is a way to delete a single device-identity:</p>
  
  <pre class="lang-bsh prettyprint-override"><code>az iot hub device-identity delete --device-id "test-id" --hub-name "test-hub"
  </code></pre>
  
  <p>How can I delete all the devices in the hub using the cli interfaces and some powershell commands?</p>