Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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