$ErrorActionPreference , , , , PowerShell.
a cmdlet : ? , Write-Host $ErrorActionPreference, Stop:
Write-Error blah
Get-ChildItem somepathwhichsurelydoesntexisthere
, , , , . , choice 1, ?
- , , . PowerShell , , , .
, :
function Invoke-NativeCommand {
$command = $args[0]
$arguments = $args[1..($args.Length)]
& $command @arguments
if (!$?) {
Write-Error "Exit code $LastExitCode while running $command $arguments"
}
}
, .