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 Microsoft 365 Junction, Speaker, Author, Learner, Developer, Passionate Techie. Certified Professional Workshop Facilitator / Public Speaker. Believe in knowledge sharing. Around 20+ years of total IT experience and 17+ years of experience in SharePoint and Microsoft 365 services Please feel free me to contact for any SharePoint / Microsoft 365 queries. I am also very much interested in behavioral (life changing) sessions like motivational speeches, Success, Goal Setting, About Life, How to live Life etc. My book - Microsoft 365 Power Shell hand book for Administrators and Beginners and 100 Power Shell Interview Questions - https://www.amazon.in/Microsoft-Administrators-Beginners-Interview-Questions/dp/9394901639/ref=tmm_pap_swatch_0?_encoding=UTF8&qid=1679029081&sr=8-11

You may also like...

Leave a Reply

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

Discover more from Microsoft 365

Subscribe now to keep reading and get access to the full archive.

Continue reading