0
私がターゲットとするマシンのリモートレジストリにHEX値のDWORDキーを書き込もうとしています。キーは、HKEY_Usersハイブの下にあり、ユーザーのSIDをターゲットとし、次に必要なパスを指定します。私の問題は常に次のエラーが表示されます:PowershellのリモートレジストリへのHEXでのDWORD値の書き込み
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
}
16進値は '0x'-prefixを使います。 '$ Value1 = 0x1f24db0a'を試してください –
完璧!正確に私はそれを動作させるために必要なもの!ありがとう – Adam