title: Convert from console to windows service error
body: <p>in my solution i have a console project <code>reg</code> to start my app and it works fine</p>
  
  <p>now i want to Replace console to a windows service <code>Service1</code>
  but it doesn't  work and give me an error to connect with database</p>
  
  <p>this is my solution and i use <code>Service1 item</code> instead Console <code>reg</code></p>
  
  <p><img src="https://i.stack.imgur.com/jjydc.png" alt="enter image description here"></p>
  
  <p>and this is my <code>onStart</code> Method</p>
  
  <pre><code>      protected override void OnStart(string[] args)
        {
              System.Diagnostics.Debugger.Launch();
                   EventLog.WriteEntry("Service Started...");
                   ConfigureServer();
        }
  </code></pre>
  
  <p>Here, the problem occurs  <strong>cannot run database xds requested by the login</strong></p>
  
  <pre><code> using (System.Management.Automation.PowerShell powershell = System.Management.Automation.PowerShell.Create())
                       {
                            powershell.Runspace = myRunSpace;
                            powershell.Commands.AddScript("Get-CsTrustedApplicationPool");
                            Collection&lt;PSObject&gt; results = null;
                            Collection&lt;ErrorRecord&gt; errors = null;
                            try
                            {
                                  results = powershell.Invoke();
                                  errors = powershell.Streams.Error.ReadAll();
                            }
  </code></pre>