title: Running SQL Server commands from Powershell?
body: <p>I'm writing a Powershell script to automate something with SQL Server, and part of that requires adding my local account to the database as an admin.</p>
  
  <pre><code>create login [MYDOMAIN\myusername] from windows
  go
  
  sp_addsrvrolemember [MYDOMAIN\myusername], 'sysadmin'
  go
  </code></pre>
  
  <p>This needs to be run through an elevated <code>sqlcmd</code> command.</p>
  
  <p>I'm new to both Powershell and SQL Server, so thank you for your help.</p>