title: Connecting to SQL Server using Windows authentication (other than my local one, in different domain) from Powershell script in Jenkins
body: <p>I need to query two databases from Jenkins to compare the returned results.
  The first one is the SQL Server database where only Windows authentication is enabled.
  The mentioned account that I use to authenticate is different than that I use on machine with Jenkins.</p>
  
  <p>I thought about writing a Powershell script to do that, because there's a Powershell plugin for Jenkins.
  Most solutions that I've found suggest either using <code>runas</code> Windows command or start a new <code>Powershell</code> process (<a href="https://social.technet.microsoft.com/Forums/scriptcenter/en-US/427e768b-a11b-4da3-abeb-131d26557d63/running-powershell-as-a-specific-user?forum=ITCG" rel="nofollow noreferrer">https://social.technet.microsoft.com/Forums/scriptcenter/en-US/427e768b-a11b-4da3-abeb-131d26557d63/running-powershell-as-a-specific-user?forum=ITCG</a>).</p>
  
  <p>However, as I understand, this opens completely new Powershell window/console and the next commands that I typed in Powershell Jenkins build step will be still executed in previous Powershell console, not the one with different user.
  Is there any workaround? Is it possible to "transfer" commands to this new Powershell process?</p>
  
  <p>Similar question was asked on SO (<a href="https://stackoverflow.com/questions/37556726/how-can-i-connect-to-sql-through-powershell-using-windows-authentication-other-t">How can I connect to SQL through PowerShell using Windows authentication other than my local one?</a>), but it doesn't help on my case (the mentioned question was not about running from Jenkins).</p>