如何使用 PowerShell 进行远程注册表更改? [英] How can I use PowerShell to make remote registry changes?
本文介绍了如何使用 PowerShell 进行远程注册表更改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经测试了以下 PowerShell 注册表设置,并且设置正确.有人可以告诉我如何为远程计算机执行此操作吗?
I have tested the following PowerShell registry settings and it sets them correctly. Could someone show me the way to do this for a remote computer?
New-Item -itemType String HKLM:\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\TrapConfiguration\Server0ps -Value "MY.DOMAIN.COM"
New-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\PermittedManagers -Name 1 -Value "whatever"
Set-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\ValidCommunities -Name "Hello" -Value 4
Set-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\ValidCommunities -Name "There" -Value 8
推荐答案
以此为例:
$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $computername )
$regKey= $reg.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",$true)
$regKey.SetValue("New_Valuename_String","New_Valuedata",[Microsoft.Win32.RegistryValueKind]::String)
要创建新密钥,您需要使用带有 invoke-command
的 powershell 远程处理 new-item
cmdlet.
To create a new key you need use powershell remoting with invoke-command
for new-item
cmdlet.
这篇关于如何使用 PowerShell 进行远程注册表更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文