If you need to expand variables contained within single quotes, thankfully it’s quite easy with “$ExecutionContext.InvokeCommand.ExpandString($string)”:

  
$opinion = "better"
  
$string = 'Cats are cool, but dogs are even $opinion'

write-host $string
  
Cats are cool, but dogs are even $opinion

…


$string = $ExecutionContext.InvokeCommand.ExpandString($string)
  
write-host $string
  
Cats are cool, but dogs are even better