but I think my way is cooler and, for some, easier to remember. You can easily add this to all FileInfo objects by updating the TypeData in PowerShell: Update-TypeData -TypeName System.IO.FileInfo -MemberName FileVersionRaw -MemberType ScriptProperty -Value | Format-List Or by pulling the data from this: ::GetVersionInfo($this.FullName) So the only way to get the updated Fileversion straight from the assembly file is to build it up yourself from the parts, something like this: Get-Item C:\Windows\System32\Lsasrv.dll | ft FileName, File*Part However, although it's correct in LSASrv, it's possible for the ProductVersion and FileVersion to be different (it's common, in fact). So with a file like lsasrv (which got replaced due to security problems in SSL/TLS/RDS in November 2014) the versions reported by these two commands (at least for a while after that date) were different, and the second one is the more "correct" version. If i could get the windows version into a variable i could build a conditional to take the right path. Basically ever since Vista, the Windows API GetFileVersionInfo is querying part of the version information from the language neutral file (exe/dll) and the non-fixed part from a language-specific mui file (which isn't updated every time the files change). 1 I'm making some batch files to personalise my windows installations faster, but I need my batch to take a road depending on which Windows version it's running on. The distinction I'm making between "original" and "patched" is basically due to the way the FileVersion is calculated ( see the docs here). Interestingly, you could get the updated (patched) ProductVersion by using this: (Get-Command C:\Windows\System32\Lsasrv.dll).Version For instance: (Get-Item C:\Windows\System32\Lsasrv.dll).VersionInfo.FileVersion In PowerShell 4, you could get the FileVersionInfo from Get-Item or Get-ChildItem, but it would show the original FileVersion from the shipped product, and not the updated version. It's actually the same ScriptProperty from my Update-TypeData in the original answer below, but built-in now. Since PowerShell 5 in Windows 10, you can look at FileVersionRaw (or ProductVersionRaw) on the output of Get-Item or Get-ChildItem, like this: (Get-Item C:\Windows\System32\Lsasrv.dll).VersionInfo.FileVersionRaw
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |