I was recently tasked with going through all the servers in our farm and identifying if there were any differences in the dll’s in the Global Assembly Cache (GAC) on each server. If you’ve ever taken a peek into the GAC on a server you’ll notice that you can’t exactly eyeball the file names, versions, all the goods. So I needed a way to extract this information into a text document so I could run a compare or a diff.

I was looking to put together a solution in PowerShell, and figured I’d check before recreating the wheel, and I found that someone had built this very solution and functions and it was available on codeplex!

You can obtain package from http://powershellgac.codeplex.com/ 

Unzip and place onto Desktop.
Then copy the Gac Folder into

C:\Windows\System32\WindowsPowershell\V1.0\Modules\  (NOTE: I’m absolutely certain that there is a better place to put this module and have it called in PowerShell and I welcome someone who lets me know where there shold be. I’ll be happy to update this thread.)

Run the command below to verify the GAC Module is available
Get-Module -ListAvailable

Execute the following command in PowerShell 2.0 to import the module
Import-Module Gac

If the Module import fails to load, run the following.
Set-ExecutionPolicy RemoteSigned

To get list of all the Gac files in a csv file run the following.   (Note: You’ll need to replace the path with a location that exists on your server.)
Get-GacAssembly | export-csv C:\Temp\gaccontents.txt  


1 thought on “Powershell Get Contents of GAC

  1. This might help add some help for users later on.

    if(@(Get-Module GAC -ListAvailable).Count -eq 0)
    Install-Module GAC -Scope CurrentUser
    Import-Module Gac

    This installs to local user module directory, adding autoloading and no admin required.

Leave a Reply

Your email address will not be published. Required fields are marked *

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