Running NServiceBusHost.exe from Powershell Running NServiceBusHost.exe from Powershell powershell powershell

Running NServiceBusHost.exe from Powershell


I generally recommend using the Start-Process cmdlet to launch processes from PowerShell. This makes the whole process (no pun intended) of launching processes much easier to troubleshoot.

You can build your command line arguments into a variable, and pass that resulting variable into the -ArgumentList parameter.

$Arguments = '/install /startManually /serviceName:{0} /displayName:{0} /username:{1} /password:{2}' -f $ServiceName, $ServiceUserName, $ServicePassword)$nServiceBus = Resolve-Path -Path nServiceBus.Host.exe;Write-Host -Object ('Argument string is: {0}' -f $Arguments);Write-Host -Object ('Path to nServiceBus.Host.exe is: {0}' -f $nServiceBus);Start-Process -Wait -NoNewWindow -FilePath $nServiceBus -ArgumentList $Arguments -RedirectStandardOutput tmp.txt;

Hope this helps.