Powershell のWrite-Error
コマンドレットが機能しないのはなぜですか? 私の出力は、ドキュメントの例のようには見えません:
PS C:\> Write-Error "This is an error"
Write-Error "This is an error" : This is an error
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException
次のような出力を期待していましたWrite-Warning
。
PS H:\> Write-Warning "This is a warning"
WARNING: This is a warning
Write-Error
およびドキュメントから、about_preference_variables
例外が表示されるべきではないと思いましたか?
PS H:\> Get-Help About_Preference_Variables
$ErrorActionPreference
----------------------
...
PS> $erroractionpreference
Continue # Display the value of the preference.
PS> write-error "Hello, World"
# Generate a non-terminating error.
write-error "Hello, World" : Hello, World
# The error message is displayed and
execution continues.
PS> write-error "Hello, World" -ErrorAction:SilentlyContinue
# Use the ErrorAction parameter with a
value of "SilentlyContinue".
PS>
# The error message is not displayed and
execution continues.