Powershell Invoke and multiple lines

Hi,

I am trying to run a 15 line code using Invoke Powershell. I can copy and paste this 15 line of code and not execute it because it misinterprets the code and gives me an error message. What possibilities are there to execute a programming code via invoke without reading it in and executing it via a read file? The code works fine via read file.

Hi @Crusha ,

Could you let us know what is that you want to perform ? You did mention the code works fine by First Reading the file and using it Invoke Powershell Activity.

Let us know what exactly is that your looking for.

I have a larger script. But I would like to work with variables in some things, e.g.:

$date = get-date -Format "yyyy_MM_dd-hhmmss"
$Log = "ErrLog_$($date).txt"
$Error.Clear()
$AktDate = get-date -Format "dd.MM.yyyy hh:mm:ss"

"Start: $($AktDate)" | Out-File $Log

$setPW = 0
$debug = 0

if($debug -eq 1){
    $PWDatei = "psK_cm.txt"
} else {
    $PWDatei = "psK.txt"
}