views:

20

answers:

1

I am using NVelocity to process various PowerShell scripts before they are executed against a server.

My question is how to escape a backslash trailing a variable:

e.g.

ls \\$computername\c$

$computername should be replaced with a valid computer name at runtime, but the trailing backslash (\c$) means that it does not.

Thanks Ben

A: 

Mauricio's suggestion did not work for me. I think this because I was referencing the c$ admin share and Velocity uses the '$' sign to declare variables/objects.

Instead I created variables to contain such references so my solution was:

#set ($C = '\c$')
ls \\\\$computername$C

As per http://velocity.apache.org/engine/devel/user-guide.html#escapingvalidvtlreferences

Ben