This repository has been archived by the owner on Oct 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Get-PublicKeyDlls-lg.ps1
50 lines (38 loc) · 1.7 KB
/
Get-PublicKeyDlls-lg.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<#
Author: Chris Dek.
.Synopsis
Extraction/Processing of public key contents from a computer's GAC..
.Description
This script opens all public key tokens from the GAC of a system with .NET installed and
also retrievs the corresponding dependent dlls from each assembly manifest on the system.
.Parameter legacyNET
Change to/from the .NET 4+ or .NET 4 (or less) GAC.
.Example
Run this file (preferably under administrative powershell cli) and you will get a list of all assembly tokens in your system.
set the -legacyNET option at the function call of Get-PKTokenWithManifest to get the dll info from older .net installations.
#>
Function Get-PKTokenwithManifest {
#
#Added support for older .NET versions..
param([switch]$legacyNET=$false)
if ($legacyNET) {
#For assemblies prior to .NET 4..
New-PSDrive -Name "GACDrive" -Root "$env:windir\assembly" -PSProvider "FileSystem"
cd GACDrive:
Get-ChildItem -Path .\*.dll -Recurse | %{
([System.Reflection.Assembly]::LoadWithPartialName($_.BaseName).FullName)
([System.Reflection.Assembly]::LoadWithPartialName($_.BaseName).ManifestModule)
[System.Reflection.Assembly]::LoadFile($_.FullName).GetReferencedAssemblies() | Select Name,Version
}
}
#Support for assemblies of .NET version 4+..
New-PSDrive -Name "DotNetGACDrive" -Root "$env:windir\Microsoft.NET\assembly" -PSProvider "FileSystem"
cd DotNetGACDrive:
Get-ChildItem -Path .\*\*.dll -Recurse | %{
([System.Reflection.Assembly]::LoadWithPartialName($_.BaseName).FullName)
([System.Reflection.Assembly]::LoadWithPartialName($_.BaseName).ManifestModule)
[System.Reflection.Assembly]::LoadFile($_.FullName).GetReferencedAssemblies() | Select Name,Version
}
cd $env:USERPROFILE\Documents\
}
Get-PKTokenwithManifest