Création de Clés de Registre avec Powershell

Je suis en train de vérifier si une clé de la structure existe dans le registre à l'aide de powershell. Si la structure n'existe pas, j'ai besoin de créer, et puis j'ai besoin de créer les clés à la fin de dossier. Si je lance le des extraits individuellement pour créer les clés, ils créent de l'amende juste. Mais l'exécution du bloc lui-même (s'assurer manuellement dans le registre que la clé n'existe pas), il ne de créer la structure de répertoire. Pas sûr de ce qu'est la question. Toute aide sera apprécier. Le code est comme suit:

$Registry_Paths = "hkcu:\Software\Microsoft\Office.0", "hkcu:\Software\Microsoft\Office.0\Groove", "hkcu:\Software\Microsoft\Office.0\Groove\Development"

foreach($Registry_Path in $Registry_Paths)
{
$Test_Path_Result = Test-Path -Path $Registry_Path
if($Test_Path_Result -eq $false)
{
    $Registry_Key_Log += "Warning: No registry key path found at " + $Registry_Path +"`n"
    $Registry_Key_Log += "Creating key now for " + $Registry_Path + "`n" + "`n"

    if($Registry_Path -eq "hkcu:\Software\Microsoft\Office.0")
    {
        try{
        New-Item -Path "HKCU:\Software\Microsoft\Office.0" -ItemType Key
        }
        catch
        {
            $Error_Log += "Warning: There was an error when attempting to create a new registry key, or key property for $Registry_Path"
            $Error_Log += $_.exception.message
        }

    }
    if($Registry_Path -eq "hcku:\Software\Microsoft\Office.0\Groove")
    {
        try{
        New-Item -Path "HKCU:\Software\Microsoft\Office.0\Groove" -ItemType Key
        }
        catch
        {
            $Error_Log += "Warning: There was an error when attempting to create a new registry key, or key property for $Registry_Path"
            $Error_Log += $_.exception.message
        }
    }
    if($Registry_Path -eq "hcku:\Software\Microsoft\Office.0\Groove\Development")
    {
        try{
        New-Item -Path "HKCU:\Software\Microsoft\Office.0\Groove\Development" -ItemType Key
        New-ItemProperty -Path "hkcu:\Software\Microsoft\Office.0\Groove\Development" -Value 00000001 -PropertyType dword -Name "EnableReleaseBuildDebugOutput"
        New-ItemProperty -Path "hkcu:\Software\Microsoft\Office.0\Groove\Development" -Value 1 -Name "TraceIdentityMessaging"
        New-ItemProperty -Path "hkcu:\Software\Microsoft\Office.0\Groove\Development" -Value 00000001 -PropertyType dword -Name "TraceTelespaceFetch"
        New-ItemProperty -Path "hkcu:\Software\Microsoft\Office.0\Groove\Development" -Value 1 -Name "TraceConnectSequence"

        }
        catch
        {
            $Error_Log += "Warning: There was an error when attempting to create a new registry key, or key property for $Registry_Path"
            $Error_Log += $_.exception.message
        }
    }

}
}
Pourriez-vous être plus clair sur ce qui "snippets" travaillé et ceux qui ne l'est pas? Est-ce à défaut de créer, ou à défaut de détecter?

OriginalL'auteur Ger | 2014-11-03