Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function script:exec {
- [CmdletBinding()]
- param(
- [Parameter(Position=0,Mandatory=1)][scriptblock]$cmd,
- [Parameter(Position=1,Mandatory=0)][string]$errorMessage = ("Error executing command: {0}" -f $cmd)
- )
- & $cmd
- if ($lastexitcode -ne 0)
- {
- throw $errorMessage
- }
- }
Add Comment
Please, Sign In to add comment