29 lines
877 B
PowerShell
29 lines
877 B
PowerShell
|
function Invoke-CallOperatorWithPathAndParameters {
|
||
|
<#
|
||
|
.SYNOPSIS
|
||
|
This function is basically just a wrapper for unit-testing purposes.
|
||
|
Used to call a system file with an array of string args.
|
||
|
The best use-case for this is sc.exe execution, or topshelf installers.
|
||
|
|
||
|
.PARAMETER Path
|
||
|
The file path being invoked
|
||
|
|
||
|
.PARAMETER Arguments
|
||
|
This value just gets splatted as passed in.
|
||
|
|
||
|
.OUTPUTS
|
||
|
This function outputs whatever came out of the called function
|
||
|
#>
|
||
|
[CmdletBinding()]
|
||
|
[OutputType([System.Object])]
|
||
|
param(
|
||
|
[Parameter(Mandatory=$true)]
|
||
|
[string]$Path,
|
||
|
[Parameter(Mandatory=$true)]
|
||
|
[string[]]$Arguments
|
||
|
)
|
||
|
|
||
|
# Fun fact: $LASTEXITCODE is set by the past .exe to run in the call stack, not by functions
|
||
|
# So if this sets a $LASTEXITCODE we can test for it in the caller function
|
||
|
(& $Path @Arguments)
|
||
|
}
|