Get .NET Framework Version of an assembly (dll/exe) using PowerShell

i just had to find the required framework version for a compiled .NET assembly (just to make sure, that the selected Application Pool in IIS was set to the righte Framework Version).

——–

$fileBrowser = New-Object System.Windows.Forms.OpenFileDialog -Property @{
 Filter = 'Assemblies (*.dll & *.exe)|*.dll'
 MultiSelect = $true}
 [void]$fileBrowser.ShowDialog()
 $files = $fileBrowser.FileNames
  
 foreach($file in $files)
 {
 $version = [System.Reflection.Assembly]::ReflectionOnlyLoadFrom($file).ImageRuntimeVersion;
 echo "$($file) is using Framework: $version"
 }
 

————–

Leave a Reply

Your email address will not be published. Required fields are marked *