Wie kann ich mit powershell die Rückkehr der korrekte exit-code beim Aufruf mit der -Datei-argument?

Powershell zurückgegeben 0 exit-code, wenn ein Fehler aufgetreten ist, wenn der Aufruf mit der -Datei-argument. Was bedeutet mein build ist grün, wenn es sollte nicht sein 🙁

Beispiel:

(in wtf.ps1)

$ErrorActionPreference = "Stop";   
$null.split()

(cmd)

powershell -file c:\wtf.ps1  
You cannot call a method on a null-valued expression.
At C:\wtf.ps1:3 char:12
+ $null.split <<<< ()
    + CategoryInfo          : InvalidOperation: (split:String) [], ParentConta
   insErrorRecordException
    + FullyQualifiedErrorId : InvokeMethodOnNull


echo %errorlevel%  
0

powershell c:\wtf.ps1  
You cannot call a method on a null-valued expression.
At C:\wtf.ps1:3 char:12
+ $null.split <<<< ()
    + CategoryInfo          : InvalidOperation: (split:String) [], ParentConta
   insErrorRecordException
    + FullyQualifiedErrorId : InvokeMethodOnNull


echo %errorlevel%  
1

Irgendwelche Ideen?

(Ich habe versucht so ziemlich jede Idee aus den ersten 2 Seiten dieses: https://www.google.co.uk/search?q=powershell+Datei+argument+exit+code schon)

InformationsquelleAutor der Frage grahamrhay | 2012-05-16

Schreibe einen Kommentar