title: How do I reference an assembly from the GAC in a PowerShell module?
body: <p>I'm writing a PowerShell module which depending on the SMO assemblies in SQL Server. (The only one I need to reference is Microsoft.SqlServer.Smo.dll)</p>
  
  <p>When I've been developing module. I've just taken a copy of the assembly I need and referenced it in my manifest file similar to this:</p>
  
  <pre><code>RequiredAssemblies = @(         
      "$env:userprofile\Documents\WindowsPowerShell\Modules\Dependencies\Microsoft.SqlServer.Smo.dll"
  )
  </code></pre>
  
  <p>I would assume that in a production environment you'd want to reference assemblies from a standard location. I'd assume a standard location would be the GAC.</p>
  
  <p>If I reference the assembly from the GAC, I get this, but this looks like it could break if a new version of the assembly is installed:</p>
  
  <pre><code>RequiredAssemblies = @(
      'C:\WINDOWS\assembly\gac_msil\Microsoft.SqlServer.Smo\12.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.Smo.dll'
  )
  </code></pre>
  
  <p>I could also reference the assembly directly from the SDK:</p>
  
  <pre><code>RequiredAssemblies = @(
      'C:\Program Files\Microsoft SQL Server\120\SDK\Assemblies\Microsoft.SqlServer.Smo.dll'
  )
  </code></pre>
  
  <p>Another option I've considered (but possibly might be breaking a EULA somewhere) is to copy the assemblies to a server share and reference that like so:</p>
  
  <pre><code>RequiredAssemblies = @(
      '\\MyServer\PowerShellDependencies\Microsoft.SqlServer.Smo.dll'
  )
  </code></pre>
  
  <p>But how should I be doing this?</p>
  
  <p>If it's relevant, all computers that this module will be installed on are 64-bit and will have the SMO libraries installed. Also, this isn't a publicly available piece of software, it's being deployed on a company network.</p>
  
  <p><strong>Update:</strong> I've tried only specifying the name of the assembly in the manifest and this appears to work.</p>
  
  <pre><code>RequiredAssemblies = @(
      'Microsoft.SqlServer.Smo.dll'
  )
  </code></pre>