How to Convert a String to a Script Block in PowerShell
To convert a string to a script block in PowerShell, use [scriptblock]::Create(). Then run it with the call operator &: It’s useful when the code comes from a config file or is built from settings, like a filter. Below I cover parameters, the quoting trap, filters, syntax checks and the security risk you need to … Read more