在同一域内的另一台 PC 上修改注册表 [英] Amending the Registry on another PC within the same domain

查看:233
本文介绍了在同一域内的另一台 PC 上修改注册表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 PowerShell 菜鸟,所以放轻松.这是我到目前为止所得到的.脚本的其余部分应该没问题.我只是在连接到域中的另一台 PC 时遇到问题.

I'm a PowerShell noob, so go easy on me. This is what I've got so far. The rest of the script should be fine. I'm just having trouble connecting to another PC on the domain.

我还启动了 RemoteRegistry 进程,所以这也不应该是一个问题(以及等待命令).

I've also started the RemoteRegistry process, so that shouldn't be an issue either (along with a wait command).

我实际上只需要找到一种方法来与同一域中的另一台 PC 进行交互.我尝试过的 cmdlet 到目前为止还没有多大用处.不过,我可能只是错误地使用了它们.我基本上只需要向远程 PC 添加一个注册表项,而不是登录到他们的机器并手动进行.

I literally just need to find a method to interact with another PC on the same domain. The cmdlets I've tried haven't been much use as of yet. I might just be using them incorrectly though. I basically just need to add a registry key to remote PCs, instead of logging on to their machine and doing it manually.

这是我迄今为止尝试过的:

This is what I've tried so far:

$computer ="xxxxxx"
Get-WmiObject Win32_BIOS -ComputerName $computer

我也试过:

$computer ="xxxxx"
Get-ADComputer -Identity $computer

推荐答案

这是一个与远程注册表交互的 wmi 方法:

Here's a wmi method to interact with a remote registry:

$PSCredential = Get-Credential
$ComputerName = Read-Host -Prompt 'Enter target computername'

$GwmiArgs = @{
    Class        = 'StdRegProv'
    Namespace    = 'Root\Default'
    List         = $True
    ComputerName = $ComputerName
    Credential   = $PSCredential
}
$Registry = Get-WmiObject @GwmiArgs

使用这个 $Registry 对象,您有以下方法:
(它们都返回一个 [System.Management.ManagementBaseObject] 对象)

With this $Registry object, you have the following methods:
(they all return a [System.Management.ManagementBaseObject] object)

CheckAccess            ([uint32] $DefKey, [string] $SubKeyName, [uint32] $Required)
CreateKey              ([uint32] $DefKey, [string] $SubKeyName)
DeleteKey              ([uint32] $DefKey, [string] $SubKeyName)
DeleteValue            ([uint32] $DefKey, [string] $SubKeyName, [string] $PropertyName)
EnumKey                ([uint32] $DefKey, [string] $SubKeyName)
EnumValues             ([uint32] $DefKey, [string] $SubKeyName)
GetBinaryValue         ([uint32] $DefKey, [string] $SubKeyName, [string] $PropertyName)
GetDWORDValue          ([uint32] $DefKey, [string] $SubKeyName, [string] $PropertyName)
GetExpandedStringValue ([uint32] $DefKey, [string] $SubKeyName, [string] $PropertyName)
GetMultiStringValue    ([uint32] $DefKey, [string] $SubKeyName, [string] $PropertyName)
GetQWORDValue          ([uint32] $DefKey, [string] $SubKeyName, [string] $PropertyName)
GetSecurityDescriptor  ([uint32] $DefKey, [string] $SubKeyName)
GetStringValue         ([uint32] $DefKey, [string] $SubKeyName, [string] $PropertyName)
SetBinaryValue         ([uint32] $DefKey, [string] $SubKeyName, [string] $PropertyName, [byte[]] $Value)
SetDWORDValue          ([uint32] $DefKey, [string] $SubKeyName, [string] $PropertyName, [uint32] $Value)
SetExpandedStringValue ([uint32] $DefKey, [string] $SubKeyName, [string] $PropertyName, [string] $Value)
SetMultiStringValue    ([uint32] $DefKey, [string] $SubKeyName, [string] $PropertyName, [string[]] $Value)
SetQWORDValue          ([uint32] $DefKey, [string] $SubKeyName, [string] $PropertyName, [uint64] $Value)
SetSecurityDescriptor  ([uint32] $DefKey, [string] $SubKeyName, [System.Management.ManagementObject#__SecurityDescriptor] $Descriptor)
SetStringValue         ([uint32] $DefKey, [string] $SubKeyName, [string] $PropertyName, [string] $Value)

并添加远程注册表项:

<#  Defined in WinReg.h:
        HKEY_CLASSES_ROOT (2147483648)
        HKEY_CURRENT_USER (2147483649)
        HKEY_LOCAL_MACHINE (2147483650)
        HKEY_USERS (2147483651)
        HKEY_CURRENT_CONFIG (2147483653)
#>
$HKEY_LOCAL_MACHINE = 2147483650
$Registry.CreateKey($HKEY_LOCAL_MACHINE, 'SYSTEM\path\to\offlinecachekey')

这篇关于在同一域内的另一台 PC 上修改注册表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆