With this new function, it is simple to create new registry keys (including missing parent keys) in all registry hives. All you need are proper permissions:
function New-RegKey { param($key) $key = $key -replace ':','' $parts = $key -split '\\' $tempkey = '' $parts | ForEach-Object { $tempkey += ($_ + "\") if ( (Test-Path "Registry::$tempkey") -eq $false) { New-Item "Registry::$tempkey" | Out-Null } } }
Look how easy it is to create multiple registry keys:
New-RegKey HKCU\Software\Test\SubKey\AnotherOne\Finally