Skip to content

Instantly share code, notes, and snippets.

@CosmosKey
Created January 24, 2017 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CosmosKey/2decc69c880a1e99502d5a46ca63e484 to your computer and use it in GitHub Desktop.
Save CosmosKey/2decc69c880a1e99502d5a46ca63e484 to your computer and use it in GitHub Desktop.
New-Module -Name tt -ScriptBlock {
$ErrorActionPreference="stop"
function t1 {
[CmdletBinding()]
param()
try {
"trying"
Get-Content c:\TheFileWhichDoesNotExist.txt
"Yiiihaaaa"
} catch {
$err = [System.Management.Automation.ErrorRecord]::new($_.Exception,"myErr",$_.CategoryInfo.Category,$null)
$PSCmdlet.WriteError($err)
}
}
} | Import-Module
t1 # implicit -EA=stop due to the EA preference set in the module above
t1 -ErrorAction SilentlyContinue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment