Skip to content

Instantly share code, notes, and snippets.

@rvrsh3ll
Forked from TheWover/Find-Assemblies.ps1
Last active February 14, 2020 03:29
Show Gist options
  • Select an option

  • Save rvrsh3ll/f053d138cc1b8eae96ccf6186b1ed002 to your computer and use it in GitHub Desktop.

Select an option

Save rvrsh3ll/f053d138cc1b8eae96ccf6186b1ed002 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