title: How can I get the Git commit hash in my PS script?
body: <p>I'm using a PowerShell script to call <code>msbuild</code> and pass in a version number to OctopusDeploy like this:</p>
  
  <pre><code>msbuild "Xyz.sln" /t:Rebuild /p:Configuration=Release /p:RunOctoPack=true /p:OctopackPackageVersion=$versionNumber
  </code></pre>
  
  <p>... where $versionNumber is generated in the PS script.  What I want to do is add the first 16 characters of the Git commit hash to the end of the version string so it will end up looking like:</p>
  
  <pre><code>2.yyyyMMdd.HHmmss-git-6d34e44340f95c2a
  </code></pre>
  
  <p>How can I do this?  Can I get <code>msbuild</code> or Visual Studio to return the current git commit hash somehow, considering they now have built-in Git support?</p>