Link to home
Start Free TrialLog in
Avatar of markc56
markc56Flag for United States of America

asked on

powershell script error modifying registry

I am attempting to push out a registry change via powershell, but I am getting the error:

The string is missing the terminator: ".
  +CategoryInfo      : ParseError: (:) [], ParentContainsErrorRecordException
  +FullyQualifiedErrorId : TerminatorExpectedAtEndOfString

The short line in the .bat file is:

powershell.exe "& Set-ItemProperty HKLM:\SOFTWARE\"abc def"\test\XXX -Name Test -value 50"


I have used this exact line many times to make registry changes and it always works. The only difference is the "white space" between the name ("abc def"). Without the quotation marks ("abc def") it errors out at "def".
ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
BTW, you can omit the ampersand if you use -Command:
powershell.exe -Command "Set-ItemProperty 'HKLM:\SOFTWARE\abc def\test\XXX' -Name Test -value 50"

Open in new window

Try This:

powershell.exe & Set-ItemProperty HKLM:\SOFTWARE\"abc def"\test\XXX -Name Test -value 50
Avatar of markc56

ASKER

The first solution with the single quotes works.  Same "expert commentor" added a second solution, omit the ampersand if you use -Command. This one worked too. I tried all four listed solutions, and these are the only two that worked.
Thank you for testing all suggestions.