I'm using Windows 2003 Server x86, Powershell 1.0 and have following head-breaking problem. When I'm trying to execute script below, I'm getting an error:
Error "=" operator: System error. (Fehler beim "="-Operator: Systemfehler.)
+ $data = <<<< Get-Content $log | % {
Here is this script:
$log = "C:\log file.txt"
$linePrefix = "PROCESS THIS LINE"
$trimStart = 25 #chars to ignore in the beginning
$started = 0
$data = Get-Content $log | % {
if ($_.length -ge $trimstart) {
$linedata = $_.substring($trimstart);
$timesline = $linedata.startswith($lineprefix);
if ($started -eq 0 -and $timesline) {
$started = 1;
}
if ($started) {
if ($timesline) {
$line = $linedata.substring($lineprefix.length).trimstart();
if ($line.contains(": ")) {
write-output $line
}
} else {
break;
}
}
}
}
However, if I execute it without $data =
assignment, it works perfectly and returns me expected values. I've also tried following statements
$data = (...)
$data = $(...)
and declaring a function with expression but without success.
Could you please give me a hint why it does happen?
UPDATE: I've tried to remove spaces before and after assigment sign and got similar error, but now powershell didn't like $data=G
string
Error "=" operator: System error (Fehler beim "="-Operator: Systemfehler.)
At C:\kosmo\scripts\ps\test.ps1:60 Symbol:7
+ $data=G <<<< et-Content $log | % {