Prevent Variable Expansion?


Is there any way to stop variable expansion happening with parameter values that are passed to a function?

For example, if I run the below function and neglect to use single quotes for the parameter value, the double dollar automatic variable is expanded:

function Test-Parameter {

Test-Parameter -String stringwithdollars$$

I realise this is just ‘how PowerShell works’ but wondered if there is anyway to foolproof this.

Test-Parameter -String 'stringwithdollars$$'

Yeah I get that. Just wondering if there’s a way to stop things messing up if someone gets lazy with the quotes or mistakenly uses double quotes.