Adding Multiple Registry Keys

With New-Item, it is easy to create new registry keys:

New-Item HKCU:\Software\Testkey

New-Item can only create one key at a time and fails if the parent key does not exist:

New-Item HKCU:\Software\Testkey\A\B\C\D

However, when you specify the -force switch, New-Item will happily create even multiple keys:

New-Item HKCU:\Software\Testkey\A\B\C\D -force

Posted Jul 02 2009, 08:00 AM by ps1
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.