Skip to content

Instantly share code, notes, and snippets.

@MHaggis
Forked from TheWover/Find-Assemblies.ps1
Created February 14, 2020 04:51
Show Gist options
  • Save MHaggis/66b4860437834c24f758336f283adffe to your computer and use it in GitHub Desktop.
Save MHaggis/66b4860437834c24f758336f283adffe to your computer and use it in GitHub Desktop.
Search a directory for .NET Assemblies, including Mixed Assemblies. Options for searching recursively, including DLLs in scope, and including all files in scope.
Param([parameter(Mandatory=$true,
HelpMessage="Directory to search for .NET Assemblies in.")]
$Directory,
[parameter(Mandatory=$false,
HelpMessage="Whether or not to search recursively.")]
[switch]$Recurse = $false,
[parameter(Mandatory=$false,
HelpMessage="Whether or not to include DLLs in the search.")]
[switch]$DLLs = $false,
[parameter(Mandatory=$false,
HelpMessage="Whether or not to include all files in the search.")]
[switch]$All = $false)
if($All)
{
Get-ChildItem -Path $Directory -Recurse:$Recurse -ErrorAction SilentlyContinue -Force | % { try {$asn = [System.Reflection.AssemblyName]::GetAssemblyName($_.fullname); $_.fullname} catch {} }
}
else
{
Get-ChildItem -Path $Directory -Filter *.exe -Recurse:$Recurse -ErrorAction SilentlyContinue -Force | % { try {$asn = [System.Reflection.AssemblyName]::GetAssemblyName($_.fullname); $_.fullname} catch {} }
if ($DLLs)
{
Get-ChildItem -Path $Directory -Filter *.dll -Recurse:$Recurse -ErrorAction SilentlyContinue -Force | % { try {$asn = [System.Reflection.AssemblyName]::GetAssemblyName($_.fullname); $_.fullname} catch {} }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment