创建
$registryKey = "HKLM:\SOFTWARE\Example"
$registryItem = New-Item -Path $registryKey -Force
读取
$registryKey = "HKLM:\SOFTWARE\Example"
$registryItem = Get-Item -Path $registryKey
Write-Host "注册表项内容:"
$registryItem.GetValueNames() | ForEach-Object { Write-Host "$_ = $($registryItem.GetValue($_))" }
修改
$propertyName = "TestValue"
$propertyValue = "This is a test value"
Set-ItemProperty -Path $registryKey -Name $propertyName -Value $propertyValue
删除
$registryKey = "HKLM:\SOFTWARE\Example"
$propertyName = "TestValue"
Remove-ItemProperty -Path $registryKey -Name $propertyName
$registryKey = "HKLM:\SOFTWARE\Example"
Remove-Item -Path $registryKey -Recurse -Force