I’m trying to invoke another application (Beyond Compare) from Powershell which requires an @ in the typical command-line:
C:\deploy>bcompare @static.diff
I’ve found Powershell’s Invoke-Expression, but when I try the following it gives me an error:
PS C:\deploy>Invoke-Expression "bcompare @static.diff"
Invoke-Expression : Cannot expand the splatted variable '@static'. Splatted variables
cannot be used as part of a property or array expression. Assign the result of the
expression to a temporary variable then splat the temporary variable instead.
At line:1 char:18
+ Invoke-Expression <<<< "bcompare @static.diff"
+ CategoryInfo : ParserError: (:) [Invoke-Expression], ParseException
+ FullyQualifiedErrorId : NoPropertiesInSplatting,Microsoft.PowerShell.Comands.InvokeExpressionCommand
I can’t get the @ to escape properly here. I’ve tried the `, @@, putting parts of the command in a temporary variable, but none of them did the trick.
If in doubt, put it into a string 🙂