SIGN UP MEMBER LOGIN:    
ARTICLE

How to install or uninstall dll in GAC using powershell

Posted by Vijai Anand Articles | Windows PowerShell March 10, 2011
In this article we will be seeing how to install or uninstall dll in GAC using powershell script.
Reader Level:

In this article we will be seeing how to install or uninstall dll in GAC using powershell script.

In this article

  • Install a dll into GAC using powershell script
  • Uninstall a dll from GAC using powershell script

Powershell Scr ipt:

Set-Alias
Name: Gacutil
Value: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\gacutil.exe

GAC1.gif

Install a dll:

Gacutil /i D:\anavijai.sample.dll

GAC2.gif

Uninstall a dll:

Gacutil /u anavijai.sample

Login to add your contents and source code to this article
share this article :
post comment
 

Some times you dont have gacutil installed on target system. you could use this code: BEGIN { Clear-Host $ErrorActionPreference = "Stop" if ( $null -eq ([AppDomain]::CurrentDomain.GetAssemblies() |? { $_.FullName -eq "System.EnterpriseServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" }) ) { [System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a") | Out-Null } $publish = New-Object System.EnterpriseServices.Internal.Publish } PROCESS { $files=get-childitem ".\Source Dependencies" *.dll -rec|where-object {!($_.psiscontainer)} foreach( $file in $files ) { $assembly = $file.fullname if ( -not (Test-Path $assembly -type Leaf) ) { throw "The assembly '$assembly' does not exist." } if ( [System.Reflection.Assembly]::LoadFile( $assembly ).GetName().GetPublicKey().Length -eq 0 ) { throw "The assembly '$assembly' must be strongly signed." } Write-Output "Installing: $assembly" $publish.GacInstall( $assembly ) } } #(c) http://codeimpossible.com/2010/7/21/Installing-Assemblies-to-GAC-with-PowerShell

Posted by Ilya Kholinov Feb 07, 2012

Hi Vijai, Often in PRODUCTION environments, you won't have GACUtil installed and you probably do not want GACUtil installed. In that case you need to drag and drop the dll in GAC. But in Windows 2008, you have to disable UAC which needs a restart. How do you get around this problem? Thanks Soumya

Posted by Soumya Bhattacharyya Apr 17, 2011
Become a Sponsor
PREMIUM SPONSORS
  • Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
    ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
Become a Sponsor