I have a SQL script that contains statements such as the following:
CREATE GROUP $MyGroup;
CREATE USER $MyUser;
Is there a way using Powershell that I can echo out the file contents with those variables replaced with their current values as set previously?
So if I had previously issued:
$MyGroup = 'group';
$MyUser = 'user';
the resultant string, after reading the file contents and substituting the variables, would be:
CREATE GROUP group;
CREATE USER user;
Yes, through the
$ExecutionContext
you can access theExpandString
function: