title: Powershell - Append Variable to an Array using For Each
body: <p>I'm currently trying to add a registry key to mutiple registry folders. However becasue you can't wildcard registry keys via group policy I'm using a ps1 script to add these keys. Essentially I would like to add a REG_Binary key with the hex value of 00 00 00 00 in this location: HKCU:\SOFTWARE\Microsoft\Office\15.0\Outlook\Profiles\name of outlook profile\c02ebc5353d9cd11975200aa004ae40e.</p>
  
  <p>I have the code that adds this key on one profile using one line of PS. This is:</p>
  
  <pre><code>$path = "HKCU:\SOFTWARE\Microsoft\Office\15.0\Outlook\Profiles\Name of Outlook Profile\c02ebc5353d9cd11975200aa004ae40e"
  
  New-ItemProperty -Path $path -Name 00030354 -PropertyType Binary -Value ([byte[]](0x00,0x00,0x00,0x00)) -Force
  </code></pre>
  
  <p>This works perfectly, however I need to do this on all folders in the profiles directory.
  I can find out all the profile names in this string via this command:</p>
  
  <pre><code>$Profilelist = get-childItem "HKCU:\Software\Microsoft\Office\15.0\Outlook\Profiles\*" | select name
  </code></pre>
  
  <p>How can I add the value "\c02ebc5353d9cd11975200aa004ae40e" to each line of this array/list?</p>
  
  <p>After adding this I will be able to use a for each command to add the key.</p>
  
  <p>If anyone knows a better way I'm open to other ideas! </p>
  
  <p>Thanks in advance! :)</p>