Guest User

Untitled

a guest
Jan 24th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. function script:exec {
  2. [CmdletBinding()]
  3.  
  4. param(
  5. [Parameter(Position=0,Mandatory=1)][scriptblock]$cmd,
  6. [Parameter(Position=1,Mandatory=0)][string]$errorMessage = ("Error executing command: {0}" -f $cmd)
  7. )
  8. & $cmd
  9. if ($lastexitcode -ne 0)
  10. {
  11. throw $errorMessage
  12. }
  13. }
Add Comment
Please, Sign In to add comment