title: Run Powershell or Command Prompt as administrator during Visual Studio Team Services build
body: <p>I am working on a project where we are delay signing the assemblies. I need to use the strong name tool a couple times during the build, to turn off strong name verification, and then to fully sign the assemblies before they are packaged. I attempted to use a powershell step to turn off verification, but it came back with this error:</p>
  
  <p>Script:</p>
  
  <pre><code>$testprojs = gci Project.*.dll -r
  $testprojs | % {
              sn -Vr $_
              write-output $("Turned off sn verification for " + $_.Name)
  }
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>Failed to open registry key -- Administrator permissions are needed to use
  the selected options. Use an administrator command prompt to complete these tasks.
  </code></pre>
  
  <p>So I created a script that would run the first one, but added the -elevated parameter. This made no difference.</p>
  
  <p>I also tried using a command prompt step instead of powershell. This also returned the same error.</p>
  
  <pre><code>For /r %g in ("Project.*.dll") DO sn -Vr %g
  </code></pre>
  
  <p>When I tried running this same script rdp'd to the build agent machine itself, it works as intended. It's only when it runs as a step in the build does it not work.</p>
  
  <p>Any ideas?</p>