Reputation: 3
I am trying to set a property in the registry and getting a strange error message. I don't understand.
New-ItemProperty "HKCU:\Software\Fortinet\FortiClient\FA_UI\VPN-6.4.1.1519" -PropertyType DWORD -Name "installed" -value "5f4053b4"
New-ItemProperty : Impossible de convertir la valeur « 5f4053b4 » en type « System.UInt32 ». Erreur : « Le format de la chaîne d'entrée est incorrect. »
Au caractère Ligne:1 : 1
+ New-ItemProperty "HKCU:\Software\Fortinet\FortiClient\FA_UI\VPN-6.4.1 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (HKEY_CURRENT_US...\VPN-6.4.1.1519:String) [New-ItemProperty], PSInvalidCastException
+ FullyQualifiedErrorId : System.Management.Automation.PSInvalidCastException,Microsoft.PowerShell.Commands.NewItemPropertyCommand
Thanks
Upvotes: 0
Views: 1221
Reputation: 61253
The value you are trying to set is in hexadecimal format. In PowerShell you need to prepend it with 0x
New-ItemProperty -Path "HKCU:\Software\Fortinet\FortiClient\FA_UI\VPN-6.4.1.1519" -PropertyType DWORD -Name "installed" -Value 0x5f4053b4
Or use the decimal value 1598051252
Upvotes: 0
Reputation: 659
The Value should not be quoted, that would make it a string.
The DWORD
value is looking for a 32-bit binary. This is causing the type conversion error you are seeing.
New-ItemProperty -Path "HKCU:\Software\Fortinet\FortiClient\FA_UI\VPN-6.4.1.1519" -PropertyType DWORD -Name "installed" -Value 5f4053b4
Upvotes: 2