function New-RegistryKey { <# .SYNOPSIS Create a new registry key .DESCRIPTION Creates key givin a path, does not create property for key. .EXAMPLE New-RegistryKey -regKey HKCU:\Environment\foo -Verbose #> [cmdletbinding()] param ( $RegKey ) $logLead = Get-LogLeadName $regKeyParent = Split-Path -Path $RegKey -Parent $regKeyName = Split-Path -Path $RegKey -Leaf try { Write-Verbose "$logLead : Testing for key's existance $RegKey" if (!(Test-RegistryKey $RegKey)) { Write-Verbose "$logLead : Creating Registery Key $RegKey" $regKeyResult = New-Item -Path $regKeyParent -Name $regKeyName Write-Host "$logLead : Registry key created." } else { throw "$logLead : Registry key already exists." } } catch [System.Management.Automation.PSArgumentException] { Write-Warning "$logLead : $RegKey exists." } catch { Write-Warning "$loglead : $_" } return $regKeyResult }