title: How To use Azure Update management for Automating patch management of all Virtual machines under a subscription including future machines
body: <ol>
  <li>I have an Azure policy which install Microsoft monitoring agent on all the VMs</li>
  <li>I have Automation Account which is linked to the Log analytics workspace.</li>
  <li>The Automation Account has a scheduler which has a dynamic query to fetch all the VMs with Tag &quot;PatchManagement&quot; Enabled = $true.</li>
  <li>The scheduler makes use of the Microsoft Runbook &quot;Patch-MicrosoftOMSComputers&quot; to apply the patched on the Dynamic VMs fetched by the above query.</li>
  </ol>
  <p>The Issue is</p>
  <ol>
  <li>The update management is not Enabled on the Automation Account and the VM's</li>
  <li>Is there a way we can automate enabling of the Update management on all the VM's created in a subscription and link into the automation account update management using the query of the scheduler.</li>
  </ol>
  <p>I followed the link &quot;<a href="https://4bes.nl/2020/07/12/automate-azure-update-management-scheduling-with-powershell/" rel="nofollow noreferrer">enter link description here</a>&quot;, to implement this solution.</p>