Need help for excaping powershell command

Hi i can not fix the escaping right this powershell command:

$worksheet.Cells.Item($i,22).Formula = "=VERKETTEN(RECHTS(VERKETTEN(`"0`";TAG(Terminplan!B$i));2);".";RECHTS(VERKETTEN(`"0`";MONAT(Terminplan!B$i));2);".";JAHR(Terminplan!B$i);" ";RECHTS(VERKETTEN(`"0`";STUNDE(Terminplan!B$i));2);":";RECHTS(VERKETTEN(`"0`";MINUTE(Terminplan!B$i));2))"
            $worksheet.Cells.Item($i,24) = "

Can someone help me to do it right?
LVL 8
Wilder_AdminAsked:
Who is Participating?
 
oBdACommented:
In a case like this, it's easier to concatenate the static strings and the variable(s), and define the static strings with single quotes:
$worksheet.Cells.Item($i, 22).Formula = '=VERKETTEN(RECHTS(VERKETTEN("0";TAG(Terminplan!B' + $i + '));2);".";RECHTS(VERKETTEN("0";MONAT(Terminplan!B' + $i + '));2);".";JAHR(Terminplan!B' + $i + ');" ";RECHTS(VERKETTEN("0";STUNDE(Terminplan!B' + $i + '));2);":";RECHTS(VERKETTEN("0";MINUTE(Terminplan!B' + $i + '));2))'

Open in new window

0
 
dsackerContract ERP Admin/ConsultantCommented:
Try using the backslash ( \ ) character to escape quotes, etc.

For example, from a command prompt, type:
powershell -command echo {"This is a \"quoted\" word}

Open in new window

You should be able to apply that technique to the Excel formula you are trying to create.
0
 
Wilder_AdminAuthor Commented:
Excellent Answer
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.