Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 776 Vote(s) - 3.53 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Use PowerShell to view contents of the Global Assembly Cache (GAC)

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

#2
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)
Reply

#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.
Reply

#4
Another option is that the [PowerShell Community Extensions][1] 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.


[1]:

[To see links please register here]

Reply

#5
If you want to search for a specific assembly in the GAC.

Also note, since MS has changed the GAC structure you can use the -Recurse option from the root to search all the GAC.

CD C:\Windows\assembly
ls -Recurse | ?{$_.Name -like "*log4net*"}
Reply

#6
As stated in [the docs][1]:

> 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.


[1]:

[To see links please register here]

Reply

#7
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

[To see links please register here]


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

[To see links please register here]


It can also be found in the PowerShell Gallery:

[To see links please register here]


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

#8
I successfully listed GAC using this code snippet:

```
New-PSDrive -Name HKCR -PSProvider 'Microsoft.PowerShell.Core\Registry' -Root HKEY_CLASSES_ROOT
Get-ItemProperty -Path 'HKCR:\Installer\Assemblies\Global' | Get-Member -MemberType NoteProperty
```
Solution taken from [here](

[To see links please register here]

).
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through