I have the following (part of a) script, which is executed from TeamCity.
try
{
$result = Invoke-Command -Session $session –ScriptBlock {
Param
(
[String]
$serviceName
)
Start-Process "C:\<some_path>\$serviceName\NServiceBus.Host.exe" "/install /serviceName:$serviceName /displayName:$serviceName" -NoNewWindow -Wait
} -ArgumentList $service
}
catch
{
$errorMessage = $_.Exception.Message
Write-Error "ERROR: NServiceBus.Host service installation failed with exception '$errorMessage'"
}
The problem is that no output is being written to the console, and thus, TeamCity will pass the build step regardless of whether or not the script block of the Invoke-Command
cmdlet succeded.
When I run the Start-Process
cmdlet locally on one of the target servers, I get the following output (which is what I would expect be returned when invoking the cmdlet using Invoke-Command
):
Running a transacted installation.
Beginning the Install phase of the installation. Installing service ... Service has been successfully installed. Creating EventLog source in log Application...
The Install phase completed successfully, and the Commit phase is beginning.
The Commit phase completed successfully.
The transacted install has completed.
One workaround is to use the -Redirectxx <some_log_file>
switch on Start-Process
, read the log file and act upon whatever its contents may be. However, I would really like to avoid this if it is possible.
I am using Powershell version 5.