title: How to "parse" Azure resource id object with powershell
body: <p>I am currently trying to pull data from an Azure policy for some automation with:</p>
  <blockquote>
  <p>(Get-AzPolicyState -Filter &quot;ComplianceState eq 'NonCompliant'&quot; | Where-Object {$<em>.PolicyDefinitionReferenceId -eq &quot;azure backup should be enabled for virtual machines_1&quot;} | Where-Object {$</em>.SubscriptionId -eq &quot;0000&quot;}).ResourceId</p>
  </blockquote>
  <p>Type Name: System.String</p>
  <p>Example output</p>
  <blockquote>
  <p>/subscriptions/00/resourcegroups/rg-test/providers/microsoft.compute/virtualmachines/vm-test</p>
  </blockquote>
  <blockquote>
  <p>/subscriptions/00/resourcegroups/rg-test2/providers/microsoft.compute/virtualmachines/vm-test2</p>
  </blockquote>
  <p>I am confused on how I can just pull the resource group name and virtual machine name only into a variable array.
  The resource group name is always preceded by /resourcegroups/ and VM name is always preceded by /virtualmachines/.</p>
  <p>Any guidance would be greatly appreciated. Thank you!</p>