I am trying to use Team City to provision a Windows 2008 R2 machine using puppet for windows. There is a TC Agent that is supposed to connect remotely and call the puppet client inside our target server. We tried to use Powershell but we had issues trying to execute puppet as an administrator so we created a C# code utility to redirect the output but it seems to be not working on TC but it works locally.
namespace RunAsAdmin
{
class Program
{
static void Main(string[] args)
{
Process proc = new Process();
Process p = new Process();
p.StartInfo.FileName = @"psexec.exe";
p.StartInfo.Arguments = "/accepteula \\\\" + args[0] + " -s \"C:\\Program Files (x86)\\Puppet Labs\\Puppet\\bin\\puppet.bat\" agent --test --no-daemonize --verbose --logdest console ";
p.StartInfo.Verb = "runas";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
p.Start();
while (p.HasExited == false) {
Console.WriteLine(p.StandardOutput.ReadLine());
}
Console.ReadLine();
p.WaitForExit();
p.Close();
}
}
}
The code works perfectly locally and with TC and no issues with the execution as an Administrator but we can no see the build output in TC.