using a verable in a string with out a space

Welcome Forums General PowerShell Q&A using a verable in a string with out a space

This topic contains 2 replies, has 2 voices, and was last updated by

3 years, 1 month ago.

  • Author
  • #33004

    Points: 0
    Rank: Member

    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

    $Filename ="D:\Folder\$a1 File.txt"

    I need to remove the spacein the file name.

    As always Thanks!!!!

  • #33007

    Points: 0
    Rank: Member

    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:


    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.

  • #33008

    Points: 0
    Rank: Member


    Thanks 🙂

The topic ‘using a verable in a string with out a space’ is closed to new replies.