title: Powershell: delete all the registry keys containing a string
body: <p>I would like to delete all the keys (<code>1000+</code>) containing <code>Python35</code> from :<code>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-2\Components</code></p>
  
  <p>For instance I would like to delete all the keys similar to that one:</p>
  
  <ul>
  <li><p>Keyname: <code>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-2\Components\0027CAECCC428F356B8D845FF8331246</code></p></li>
  <li><p>Name: <code>0F617A7B1C879BC47865E0155CDD6722</code> </p></li>
  <li>Data: <code>C:\Users\Me\AppData\Local\Programs\Python\Python35\Lib\venv\__init__.py</code></li>
  </ul>
  
  <p>I tried this. </p>
  
  <pre><code>Get-ChildItem -path HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-2\Components\ -Recurse | where { $_.Name -match 'Python35'} | Remove-Item -Force
  </code></pre>
  
  <p>Powershell runs without error,but when I check it in the registry, the keys are still there. </p>
  
  <p>Powershell is run as admin and Admin has the ownership of the key <code>HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-2\Components</code> and also full control on that key and its subkeys.</p>