PowerShell Script to install assembly in GAC on Windows Server 2019

Install assembly to GAC
Install assembly to GAC

Hi All,

Greetings for the day 🙂 LIFE IS BEAUTIFUL 🙂

Today very small script – to add / install assembly into GAC on Windows server onwords. As I need to search bit so thought to share. SHARING IS CARING 🙂

Prior to Windows Server 12 there were very easy way to add / install assembly into GAC – just drag and drop into assembly folder by opening in Windows Explorer

But for Windows Server 19 there is no simple drag and drop way and no GACUtil.exe directly available on server

Detailed Steps :

  • Run the SharePoint PowerShell console as administrator
  • Load the assembly – System.EnterpriseServices using Load method as
[System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")

$objPublish = New-Object System.EnterpriseServices.Internal.Publish

  • Once we have instance of System.EnterpriseServices.Internal.Publish class we are ready to call the method GacInstall(file path of assembly)
$objPublish.GacInstall("D:\PS\missing dlls\Microsoft.Practices.SharePoint.Common.dll")

  • As usual to have effect we need to do IISRESET
PowerShell script to install assembly in GAC on Windows server 2019
Fig : PowerShell script to install assembly in GAC on Windows server 2019

Complete Script :

PS C:\Users\prasham> [System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a") 

PS C:\Users\prasham> $objPublish = New-Object System.EnterpriseServices.Internal.Publish

PS C:\Users\prasham> $objPublish.GacInstall("D:\PS\missing dlls\Microsoft.Practices.SharePoint.Common.dll")

PS C:\Users\prasham> iisreset

Thanks for reading 🙂 Enjoy the beautiful life 🙂 HAVE A SAFE LIFE 🙂 TAKE CARE 🙂

Prasham Sabadra

LIFE IS VERY BEAUTIFUL :) ENJOY THE WHOLE JOURNEY :) Founder of Knowledge Junction and live-beautiful-life.com, Author, Learner, Passionate Techie, avid reader. Certified Professional Workshop Facilitator / Public Speaker. Scrum Foundation Professional certificated. Motivational, Behavioral , Technical speaker. Speaks in various events including SharePoint Saturdays, Boot camps, Collages / Schools, local chapter. Can reach me for Microsoft 365, Azure, DevOps, SharePoint, Teams, Power Platform, JavaScript.

You may also like...

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: