Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Replacing a "tag" in a Variable with Value from Another

Avatar of D B
D BFlag for United States of America asked on
Powershell
1 Comment1 Solution407 ViewsLast Modified:
I have a parameter file in CVS format that I process within powershell scripts. The file is in the format of:
VariableName, Value
Several of the variables include the path to specific files. The 'root' of this path is always the same, and in one instance is used several times in a variable (it is actually the commandline parameters for an SSIS package, executed with DtExec.exe.

What I would like to do is have something like:
ROOT,C:\SomeFolder\SomeFolder2\SomeFolder3\HomeFolder
PACKAGE_CMD_LINE,/FILE "%ROOT%\MyPackage.dtsx" /CONFIGFILE "%ROOT%\MyConfig1.dtsConfig" /CONFIGFILE "%ROOT%\MyConfig2.dtsConfig"  /WARNASERROR  /CHECKPOINTING OFF  /REPORTING EWD /CONSOLELOG NCOT 
in my parameter file. Within Pwershell, it will set the values of $ROOT and $PACKAGE_CMD_LINE to the appropriate values. Then, within the code, I want Powershell to replace the '%ROOT%' "tags" within the $PACKAGE_CMD_LINE variable with the value of the $ROOT variable, which has already been processed. Can someone assist me as to how this might be accomplished.
Subsequently, I would have a line that reads:
& DtExec.exe $PACKAGE_CMD_LINE
But $PACKAGE_CMD_LINE would have had occurances of '%ROOT%' replaced with the value of $ROOT.
ASKER CERTIFIED SOLUTION
Avatar of D B
D BFlag of United States of America imageDatabase Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 1 Comment.
See Answers