Get-GacAssemblyInstallReference.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
<#
.SYNOPSIS
    Gets the InstallReference of assemblies in the GAC
.DESCRIPTION
    Gets the InstallRefernence of assemblies in the GAC. InstallRefernence shows if an assembly
 is referenced by an installer.
.PARAMETER AssemblyName
    Specifies the assembly name. Must be fully qualified. See Test-AssemblyNameFullyQualified.
.INPUTS
 [System.Reflection.AssemblyName[]]
.EXAMPLE
    C:\PS> Get-GacAssembly -Name System | Get-GacAssemblyInstallReference
  
    Type Identifier Description
 ---- ---------- -----------
 Opaque {71F8EFBF-09AF-418D-91F1-52707CDFA274} .NET Framework Redist Setup
    Opaque {71F8EFBF-09AF-418D-91F1-52707CDFA274} .NET Framework Redist Setup
 
    This example returns the InstallReferences from the System assemblies in the GAC.
.LINK
 Test-AssemblyNameFullyQualified
.LINK
 http://powershellgac.codeplex.com
#>

function Get-GacAssemblyInstallReference
{
    [CmdletBinding()]
    [OutputType('PowerShellGac.InstallReference')]
    param
    (
        [Parameter(Position = 0, Mandatory = $true, ValueFromPipeline = $true)]
        [ValidateNotNullOrEmpty()]
        [ValidateScript( { Test-AssemblyNameFullyQualified $_ } )]
        [System.Reflection.AssemblyName[]] $AssemblyName
    )

    process
    {
        foreach ($assmName in $AssemblyName)
        {
            [PowerShellGac.GlobalAssemblyCache]::GetInstallReferences($assmName)
        }
    }
}