Skip to content

Instantly share code, notes, and snippets.

@colinangusmackay
Created September 18, 2016 20:50
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 colinangusmackay/f8fe6590dd83309261af076f46c19fef to your computer and use it in GitHub Desktop.
Save colinangusmackay/f8fe6590dd83309261af076f46c19fef to your computer and use it in GitHub Desktop.
function Invoke-CallOperator
{
[CmdletBinding(DefaultParameterSetName="Verbose")]
param
(
[parameter(Mandatory=$true)]
[string]$ExeFilePath,
[parameter(Mandatory=$true)]
[string[]]$Args
)
$IsVerbose = $PSCmdlet.MyInvocation.BoundParameters["Verbose"].IsPresent
if ($IsVerbose)
{
Write-Host "Exe: $ExeFilePath";
$args | ForEach-Object {Write-Host " * $_"}
}
if ($PSVersionTable.PSVersion.Major -le 4)
{
$args = [System.String]::Join(" ", $args);
}
$consoleOutput =& $ExeFilePath $args
$processWorked = $?
if ($IsVerbose)
{
$consoleOutput | ForEach-Object {Write-Host $_}
}
return $processWorked
}
Export-ModuleMember -Function Invoke-CallOperator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment