In this article we will be seeing how to install or uninstall dll in GAC using powershell script.
In this article
Powershell Scr ipt: Set-Alias Name: Gacutil Value: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\gacutil.exe Install a dll: Gacutil /i D:\anavijai.sample.dll Uninstall a dll: Gacutil /u anavijai.sample
How to install or uninstall dll in GAC using powershell
How to configure User Profile Service application in partition mode
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
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