Bug #14449
openWe can not execute powershell command using $_ variable
Description
When we write a command powershell to a parameter in the technique editor or in the directives using a $_ variable like in :
(Get-ItemProperty 'Registry::HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*' | where-object { $_.DisplayName -eq "Rudder agent (DSC)" } )
It will fail on the agent. The complete string will end up under double quotes BUT, in powershell, the $_ sign is interpreted before assignment if enclosed in double quotes. Resulting in an unusable command line.
see: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-expression?view=powershell-6
Dirty solution would be to let the user make the escape of the $ sign, but this is not possible since it needs a ` char which will automatically be escaped with another ` by Rudder.
I have no idea of what the correct solution is. Since the user should not know that a backquote is needed before its $ sign in this specific case (depends on the code).