As described here, you can access Octopus variables in powershell scripts in two ways. The first way is $MyVariable, where MyVariable is the name of an Octopus Deploy variable with special characters and spaces stripped out. This is what you are seeing.

The other way of accessing variables in powershell is by using the provided OctopusParameters dictionary. So to access the same variable, you would use $OctopusParameters["MyVariable"]. This second form preserves any spaces or special characters, so in your example you could access this same variable with $OctopusParameters["Test Variable With Spaces"].