How do I reference an assembly from the GAC in a PowerShell module? How do I reference an assembly from the GAC in a PowerShell module? powershell powershell

How do I reference an assembly from the GAC in a PowerShell module?


Unless you're going to deploy the SMO assemblies as private assemblies, then I wouldn't recommend loading them from direct references.

To load from the GAC, use the Add-Type cmdlet with the fully qualified assembly name...

Add-Type -AssemblyName "Microsoft.SqlServer.Smo, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"

Related:How do I use Add-Type to load Microsoft.Web.Deployment?


You can also specify just the assembly without the version info:

Add-Type -AssemblyName "System.Xml.Linq"