|
|
|
@ -7,14 +7,16 @@ Pester extension that allows to run command and validate exit code
|
|
|
|
|
|
|
|
|
|
function Get-CommandResult {
|
|
|
|
|
Param (
|
|
|
|
|
[Parameter(Mandatory)][string] $Command
|
|
|
|
|
[Parameter(Mandatory=$true)]
|
|
|
|
|
[string] $Command,
|
|
|
|
|
[switch] $Multiline
|
|
|
|
|
)
|
|
|
|
|
# CMD trick to suppress and show error output because some commands write to stderr (for example, "python --version")
|
|
|
|
|
[string[]]$output = & $env:comspec /c "$Command 2>&1"
|
|
|
|
|
$exitCode = $LASTEXITCODE
|
|
|
|
|
|
|
|
|
|
return @{
|
|
|
|
|
Output = $output
|
|
|
|
|
Output = If ($Multiline -eq $true) { $output } else { [string]$output }
|
|
|
|
|
ExitCode = $exitCode
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|