markc56
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: (:) [], ParentContainsErrorRecordE xception
+FullyQualifiedErrorId : TerminatorExpectedAtEndOfS tring
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".
The string is missing the terminator: ".
+CategoryInfo : ParseError: (:) [], ParentContainsErrorRecordE
+FullyQualifiedErrorId : TerminatorExpectedAtEndOfS
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try This:
powershell.exe & Set-ItemProperty HKLM:\SOFTWARE\"abc def"\test\XXX -Name Test -value 50
powershell.exe & Set-ItemProperty HKLM:\SOFTWARE\"abc def"\test\XXX -Name Test -value 50
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.
Open in new window