Scan folder of dlls to identify x86 or x64 compiled assemblies
powershell
Point this at a directory of dlls and you can get some of the loaded assembly details to quickly identify what type of processor architecture they were compiled for.I did this as I wanted to explore a large directory of dlls and see if I had mixed assemblies of x32 and x64 together from a visual studio build. Some dlls with invalid assembly header information were found, and this skips those as warnings.
Powershell Scan Folder For DLL ProcessorArchitecture
#requires -Version 5.0
# sheldonhull.com
# 2016-11-21 wrote to help parse directory of dlls and identify the processor architecture they were compiled for
#to use with earlier version just take out write-warning. If you are on an older version... why! Update to latest powershell version. It's quick and painless and some great perks!
param([Parameter(Mandatory = $false)][string]$Path='C:\temp\dlls')
$objectCollection=@()
$dlls = Get-ChildItem -Path $Path -Filter "*.dll"
foreach($d in $dlls)
{
try {
$AssemblyDetail = ([system.reflection.assemblyname]::GetAssemblyName($d.FullName)) | select name,ProcessorArchitecture
Add-Member -InputObject $d -MemberType NoteProperty -Name "AssemblyName" -Value $AssemblyDetail.Name -Verbose
Add-Member -InputObject $d -MemberType NoteProperty -Name "ProcessorArchitecture" -Value $AssemblyDetail.ProcessorArchitecture -Verbose
}
catch
{
Add-Member -InputObject $d -MemberType NoteProperty -Name "AssemblyName" -Value $D.BaseName -Verbose
Add-Member -InputObject $d -MemberType NoteProperty -Name "ProcessorArchitecture" -Value 'error loading' -Verbose
Write-Warning "Warning: Unable to load assembly $($d.BaseName)"
write-warning $_.Exception.Message
}
}
$dlls | select AssemblyName, ProcessorArchitecture | out-gridview