Use PowerShell to view contents of the Global Assembly Cache (GAC)

30,244

Solution 1

Another option is that the PowerShell Community Extensions installs a GAC provider, so you can do this:

dir gac:

If you are on PowerShell V2, be sure to grab the 1.2 Beta.

Solution 2

As stated in the docs:

Starting with the .NET Framework 4, the default location for the global assembly cache is %windir%\Microsoft.NET\assembly. In earlier versions of the .NET Framework, the default location is %windir%\assembly.

You may want to search in the appropriate subdir or even in both of them.

Solution 3

To list entries in the GAC;

gacutil -l

In powershell you could parse the text output of the above. I don't know of a managed interface to inspect the GAC.

Solution 4

I had the same question. The question became more prominent with .Net 4.0 and there not being a Windows Explorer shell plugin available to view the contents. GacUtil works, but is not flexible enough and takes a lot to install. The PowerShell Community Extensions option is to limited in it's functionality and contains to many other CmdLets that I don't need. Therefore I've written my own PowerShell module to view and change the GAC. It can be found on http://powershellgac.codeplex.com

This project has moved to GitHub. You can now find it on:

https://github.com/LTruijens/powershell-gac

It can also be found in the PowerShell Gallery:

https://www.powershellgallery.com/packages/Gac/1.0.1

# Show the assemblies in the GAC, including the file version
Get-GacAssembly SomeCompany* | Format-Table -View FileVersion

Solution 5

You can do it just from a command prompt:

cd C:\Windows\assembly
dir

The GAC has a specific directory structure, and you should not go moving or deleting things in there using the command prompt - rather use windows explorer (gui) or gacutil (cli)

Share:
30,244

Related videos on Youtube

GuyBehindtheGuy
Author by

GuyBehindtheGuy

Updated on November 03, 2020

Comments

  • GuyBehindtheGuy
    GuyBehindtheGuy over 3 years

    Is there a way to use PowerShell to view the contents of the GAC?

  • Cheeso
    Cheeso about 15 years
    kewl. I did not know about that.