Project

General

Profile

Actions

Bug #14449

open

We can not execute powershell command using $_ variable

Added by Félix DALLIDET about 5 years ago. Updated 13 days ago.

Status:
New
Priority:
N/A
Assignee:
-
Category:
Generic methods
Target version:
Severity:
Major - prevents use of part of Rudder | no simple workaround
UX impact:
User visibility:
Operational - other Techniques | Rudder settings | Plugins
Effort required:
Priority:
0
Name check:
Fix check:
Regression:

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).

Actions

Also available in: Atom PDF