Get Dll VersionInfo Using PowerShell


let’s not mince words: PowerShell is great. It’s ability to leverage .NET as well as it’s use of modules makes it Object Oriented. And so recently I needed to get the VersionInfo of a given DLL, and so was able to write up a module that did exactly that.

[code language=”powershell”]

function Get-DllVersionInfo
[string] $Dll
if(!(Test-Path $Dll -PathType leaf))
Write-Error -message “The path to $Dll is either not accessible or does not exist”
$fileType = [IO.Path]::GetExtension($Dll)
if ($fileType -ne ‘.dll’)
Write-Error -Message “The file type at end of $Dll is not a dll.”
$VersionInfo = (Get-Item $Dll).VersionInfo
$FileVersion = (“{0}.{1}.{2}.{3}” -f $VersionInfo.FileMajorPart,
return $FileVersion


Inheriting this value then allows you to do as you wish!


Leave a Reply

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