-1

Is a function call in a verbatim PowerShell string a thing?

CSharp example:

$"this my { GetSomeValue() }"; 

I would rather not extract a variable if I don't have to.

ArK
  • 20,698
  • 67
  • 109
  • 136
agartee
  • 445
  • 2
  • 15

1 Answers1

1

I always do it this way:

$verbatimString = 'something' + (GetSomeValue) + 'end'

Since it's verbatim string, you cannot do any trick, to put value directly into it, like you showed in your example. Remember to call functions without (), you can read about it here: 4988226

Community
  • 1
  • 1
PatrykMilewski
  • 922
  • 8
  • 17