Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Foobar {
- throw "Error in FooBar"
- }
- function Bar {
- FooBar
- }
- function Foo {
- Bar
- }
- try {
- $sb = ${function:Foo}
- $sb.Invoke()
- }
- catch {
- $ErrorMessage = $_.Exception.Message
- $line = $_.InvocationInfo.ScriptLineNumber
- $script_name = $_.InvocationInfo.ScriptName
- write-host "<--Error: Occurred on line $line in script $script_name."
- Write-host "<--Error: $ErrorMessage"
- }
- $sb = ${function:Foo}
- $sb.Invoke()
- $func_info = get-command Foo
- Invoke-Command $func_info.ScriptBlock
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement