Powershell - expand variable in in single-quote string Apr 20, 2017 • weznagwama 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