using a verable in a string with out a space

This one should be easy and I should be able to find it online but I must not be asking the google machine the right question.
I need to use a verable as part of a file name nested in another verable.
Simply put I need to set a verable that points to a file name. And that file name I need to pull its verable from a param passed via the cmd line.
Looks something like this

Param([Parameter(Mandatory=$true)][String]$a1
$Filename ="D:\Folder\$a1 File.txt"

I need to remove the spacein the file name.

As always Thanks!!!

You can place the variable name in curly braces to help the parser figure out which part is the variable, and which is the string after it:

"${a1}File.txt"

You can also use the subexpression operator, but I prefer the first option instead. You can see why when you look at this code in the ISE; the syntax highlighting is nice and neat with the braced variable names.

"$($a1)File.txt"

Perfact!!!

Thanks :slight_smile: