You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] cmd.run quotation handling with Windows and Powershell #68118
changed the title [-][BUG] cmd.run quotation handling with Window and Powershell[/-][+][BUG] cmd.run quotation handling with Windows and Powershell[/+]on Jun 26, 2025
Checkout this other issue. Might be a dup or overlap #68096
That's a good call. Case 3 & 4 in that issue are fixed by 68056, which references commands wrapped in parens. There may be some overlap, my example just shows that it also applies to commands wrapped in quotes.
@dwoz@twangboy I still see this issue in 3006.13. I made a mistake in my initial bug report. We installed via msi, not exe, in case that matters. I did test with both msi and exe though and saw the same results.
I fully uninstalled the Salt Minion and started with a fresh install of 3006.10, then installed 3006.11 and 3006.13 to test, then back to 3006.10.
The Salt Master stayed at 3006.11 through an initial run of this test. Then I upgraded the master to 3006.13 with no change in behavior.
salt 'minion' grains.get saltversion
minion:
3006.10
salt 'minion' cmd.run 'echo "This is a test"' shell=powershell
minion:
This is a test
salt 'minion' grains.get saltversion
minion:
3006.11
salt 'minion' cmd.run 'echo "This is a test"' shell=powershell
minion:
This
is
a
test
salt 'minion' grains.get saltversion
minion:
3006.13
salt 'minion' cmd.run 'echo "This is a test"' shell=powershell
minion:
This
is
a
test
salt 'minion' grains.get saltversion
minion:
3006.10
salt 'minion' cmd.run 'echo "This is a test"' shell=powershell
minion:
This is a test
Adding a little more context from some testing today. While I initially called out quotes as the issue, it seems to be certain separators within the quotes. Spaces in the case I've mentioned, but also commas.
salt 'minion' grains.get saltversion
minion:
3006.13
salt 'minion' cmd.run 'echo "This,is,a,test"' shell=powershell
minion:
This
is
a
test
I noticed this while running another state that sends a comma separated list, and only the first value was being parsed.
That might make this issue more closely related to 68095
# salt 'MINION*' cmd.run '$p = Get-Printer "Main-Copier"; if ($p -and $p.DriverName -eq "HP Universal Printing PCL 6") { exit 0 } else { exit 1 }' shell=powershell
MINION:
At line:1 char:68
+ ... et-Printer Main-Copier; if ($p -and $p.DriverName -eq HP Univ ...
+ ~
You must provide a value expression following the '-eq' operator.
At line:1 char:69
+ ... Printer Main-Copier; if ($p -and $p.DriverName -eq HP Univers ...
+ ~~
Unexpected token 'HP' in expression or statement.
At line:1 char:69
+ ... Printer Main-Copier; if ($p -and $p.DriverName -eq HP Univers ...
+ ~~
Missing closing ')' after expression in 'if' statement.
At line:1 char:96
+ ... r; if ($p -and $p.DriverName -eq HP Universal Printing PCL 6) { exit ...
+ ~
Unexpected token ')' in expression or statement.
At line:1 char:109
+ ... p.DriverName -eq HP Universal Printing PCL 6) { exit 0 } else { exit ...
+ ~~~~
Unexpected token 'else' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : ExpectedValueExpression
-------------------------------------------
Summary
-------------------------------------------
# of minions targeted: 1
# of minions returned: 1
# of minions that did not return: 0
# of minions with errors: 1
-------------------------------------------
ERROR: Minions returned with non-zero exit code
# salt 'MINION*' cmd.run "$p = Get-Printer 'Main-Copier'; if ($p -and $p.DriverName -eq 'HP Universal Printing PCL 6') { exit 0 } else { exit 1 }" shell=powershell
MINION:
& : The term '=' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:3
+ & = Get-Printer 'Main-Copier'; if ( -and .DriverName -eq 'HP Universa ...
+ ~
+ CategoryInfo : ObjectNotFound: (=:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
-and : The term '-and' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:37
+ & = Get-Printer 'Main-Copier'; if ( -and .DriverName -eq 'HP Universa ...
+ ~~~~
+ CategoryInfo : ObjectNotFound: (-and:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
-------------------------------------------
Summary
-------------------------------------------
# of minions targeted: 1
# of minions returned: 1
# of minions that did not return: 0
# of minions with errors: 1
-------------------------------------------
ERROR: Minions returned with non-zero exit code
# salt 'MINION*' test.version
MINION:
3007.6
-------------------------------------------
Summary
-------------------------------------------
# of minions targeted: 1
# of minions returned: 1
# of minions that did not return: 0
# of minions with errors: 0
-------------------------------------------
#
Activity
[-][BUG] cmd.run quotation handling with Window and Powershell[/-][+][BUG] cmd.run quotation handling with Windows and Powershell[/+]ITJamie commentedon Jun 26, 2025
Checkout this other issue. Might be a dup or overlap #68096
Obiron801 commentedon Jun 26, 2025
That's a good call. Case 3 & 4 in that issue are fixed by 68056, which references commands wrapped in parens. There may be some overlap, my example just shows that it also applies to commands wrapped in quotes.
dwoz commentedon Jun 26, 2025
3006.13 was released today. I think it might resolve this. @twangboy ?
twangboy commentedon Jun 27, 2025
Please test this on 3006.13. It seems to be working for me.
Obiron801 commentedon Jun 27, 2025
@dwoz @twangboy I still see this issue in 3006.13. I made a mistake in my initial bug report. We installed via msi, not exe, in case that matters. I did test with both msi and exe though and saw the same results.
I fully uninstalled the Salt Minion and started with a fresh install of 3006.10, then installed 3006.11 and 3006.13 to test, then back to 3006.10.
The Salt Master stayed at 3006.11 through an initial run of this test. Then I upgraded the master to 3006.13 with no change in behavior.
Obiron801 commentedon Jun 27, 2025
Adding a little more context from some testing today. While I initially called out quotes as the issue, it seems to be certain separators within the quotes. Spaces in the case I've mentioned, but also commas.
I noticed this while running another state that sends a comma separated list, and only the first value was being parsed.
That might make this issue more closely related to 68095
twangboy commentedon Jun 30, 2025
I'll look at this some more
darkpixel commentedon Jul 7, 2025
This also appears to be hitting 3007.5.
darkpixel commentedon Jul 24, 2025
Can the fix go into 3007.x too?
twangboy commentedon Jul 31, 2025
We merge fixes from the 3006.x branch to all later branches. #68156 should merge forward into higher branches.