0
我正在尝试在目标机器上的远程注册表中写入HEX值DWORD键。关键在于HKEY_Users配置单元,并且定位用户的SID,然后是我需要的路径。我的问题在于不断收到以下错误:以十六进制将DWORD值写入Powershell中的远程注册表
Exception calling "SetValue" with "3" argument(s): "The type of the value object did not match the specified RegistryValueKind or the object could not be properly converted."
这是我的脚本;与远程注册表的连接也起作用,就像确定用户的SID一样。任何人都可以看到我要去哪里吗?
$Value1 = "1f24db0a"
$Value2 = "062efc0a"
$remoteuser = Read-Host 'Enter Username of User'
$Comptername = Read-Host 'Enter Asset Number of User'
$userLogin = New-Object System.Security.Principal.NTAccount(“TestDomain“,$remoteuser)
$userSID = $userLogin.Translate([System.Security.Principal.SecurityIdentifier])
If (Test-Connection $Comptername -count 1) {
$subkey = $userSID.value+"\Software\SoftwareVendor\Application"
$type = [Microsoft.Win32.RegistryHive]::Users
$regkey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($type,$Computername)
$regkey.OpenSubKey($subkey, $true)
$regkey.SetValue('CommsServer1', $Value1, 'DWORD')
$regkey.SetValue('CommsServer2', $Value2, 'DWORD')
}
else
{
Write-Host "User's computer unreachable! Please try again!"
PAUSE
}
十六进制值使用“0x”前缀。试试'$ Value1 = 0x1f24db0a' –
完美!确切地说,我需要它来工作!谢谢 – Adam