2 Replies Latest reply on May 18, 2018 6:49 AM by ganapa2000

    How To use variable in filename

    ganapa2000 Enthusiast

      Hi All,

       

      filename giving error when used with multiple variable

       

      $Today = Get-Date -format dd-MMM-yyyy-HH-mm-ss-tt

      $serv = "myserver"

      $filename = ".\"ExistingTranscript_ + $serv + _ + $Today".txt"

       

      get-vm | out-file -path $filename

       

      Error

       

      At line:1 char:17

      + $filename = ".\"ExistingTranscript_ + $serv + _ + $Today".txt"

      +                 ~~~~~~~~~~~~~~~~~~~

      Unexpected token 'ExistingTranscript_' in expression or statement.

          + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException

          + FullyQualifiedErrorId : UnexpectedToken

       

      Please help, how can I create a filename combining two or more variables