Windows powershell error when modifying windows service parameter

  powershell, registry, windows

I am trying to update one of the parameters of Windows Service (kubelet) by using this link

1.  $regkey = "HKLMSYSTEMCurrentControlSetServiceskubelet"
2.  $name = "ImagePath"
3.  $(reg query ${regkey} /v ${name} | Out-String) -match "(?s)${name}.*(C:.*kubelet.exe.*)"
4.  $kubelet_cmd = $Matches[1] -replace "--image-pull-progress-deadline=.* ","" -replace "rn"," "
5.  reg add ${regkey} /f /v ${name} /t REG_EXPAND_SZ /d "${kubelet_cmd} --image-pull-progress-deadline=40m "

Step #3 output

PS C:UsersAdministrator> $(reg query ${regkey} /v ${name} | Out-String) -match "(?s)${name}.*(C:.*kubelet.exe.*)"
True

Output of Steps 4 and 5

PS C:UsersAdministrator> $kubelet_cmd = $Matches[1] -replace "--image-pull-progress-deadline=.* ","" -replace "rn"," "

PS C:UsersAdministrator> reg add ${regkey} /f /v ${name} /t REG_EXPAND_SZ /d "${kubelet_cmd} --image-pull-progress-deadline=40m "
ERROR: Invalid syntax.
Type "REG ADD /?" for usage.

I am not sure which part of reg add is causing this error. Kindly let me know what am I doing wrong

Source: Windows Questions

LEAVE A COMMENT