Skip to content

Instantly share code, notes, and snippets.

Created July 29, 2010 06:28
Show Gist options
  • Save anonymous/497402 to your computer and use it in GitHub Desktop.
Save anonymous/497402 to your computer and use it in GitHub Desktop.
#requires -version 2.0
[CmdletBinding()]
param (
[parameter(Mandatory=$true)]
[ValidateScript({ $_ | Test-Path -PathType Leaf })]
[string]
$Path
)
$ErrorActionPreference = 'Stop'
Set-PSDebug -Strict
Write-Output $Path
$ParentPath = $Path | Split-Path -Parent -Resolve
$TempDomainName = 'TempDomain' + [Guid]::NewGuid().ToString()
$DomainSetup = New-Object -TypeName AppDomainSetup
$DomainSetup.ApplicationBase = $ParentPath
$TempDomain = [AppDomain]::CreateDomain($TempDomainName, $null, $DomainSetup)
$AsmName = [Reflection.AssemblyName]::GetAssemblyName($Path)
#[byte[]]$AsmBytes = [IO.File]::ReadAllBytes($Path)
write-verbose "Base: $($TempDomain.BaseDirectory)"
write-verbose "Rel: $($TempDomain.RelativeSearchPath)"
exit
$Asm = $TempDomain.Load($AsmName)
Write-Verbose "Parsing references"
$Asm.GetReferencedAssemblies() |
ForEach-Object {
$Asm = $TempDomain.Load($_)
if (-not $Asm.GlobalAssemblyCache) {
Write-Output $_.Location
# TODO recurse
}
}
[AppDomain]::Unload($TempDomain)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment