powershell을 사용하여 레지스트리에 키 구조가 있는지 확인하려고합니다. 구조체가 존재하지 않으면 생성해야하고 끝 폴더에 키를 만들어야합니다. 스 니펫을 개별적으로 실행하여 키를 만들면 괜찮습니다. 그러나 블록 자체를 실행 (레지스트리 내에 수동으로 키가 존재하지 않음을 확인)하면 폴더 구조가 생성되지 않습니다. 문제가 무엇인지 잘 모릅니다. 어떤 도움을 주시면 감사하겠습니다.Powershell로 레지스트리 키 만들기
다음$Registry_Paths = "hkcu:\Software\Microsoft\Office\14.0", "hkcu:\Software\Microsoft\Office\14.0\Groove", "hkcu:\Software\Microsoft\Office\14.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\14.0")
{
try{
New-Item -Path "HKCU:\Software\Microsoft\Office\14.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\14.0\Groove")
{
try{
New-Item -Path "HKCU:\Software\Microsoft\Office\14.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\14.0\Groove\Development")
{
try{
New-Item -Path "HKCU:\Software\Microsoft\Office\14.0\Groove\Development" -ItemType Key
New-ItemProperty -Path "hkcu:\Software\Microsoft\Office\14.0\Groove\Development" -Value 00000001 -PropertyType dword -Name "EnableReleaseBuildDebugOutput"
New-ItemProperty -Path "hkcu:\Software\Microsoft\Office\14.0\Groove\Development" -Value 1 -Name "TraceIdentityMessaging"
New-ItemProperty -Path "hkcu:\Software\Microsoft\Office\14.0\Groove\Development" -Value 00000001 -PropertyType dword -Name "TraceTelespaceFetch"
New-ItemProperty -Path "hkcu:\Software\Microsoft\Office\14.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
}
}
}
}
"스 니펫"이 효과가 있고 어떤 것이 효과가 없었습니까? * 생성 * 실패 * 탐지 * 실패? – briantist