找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 21266|回复: 1

[转载代码] [PowerShell每日技巧]获取DLL文件的版本信息(20131204)

[复制链接]
发表于 2013-12-5 13:35:30 | 显示全部楼层 |阅读模式
Ever needed a list of DLL files and their versions? Get-ChildItem can get this information for you. You just need to unpack some properties like so:
  1. Get-ChildItem c:\windows\system32\*.dll |
  2.   Select-Object -ExpandProperty VersionInfo |
  3.   Select-Object -Property FileName, Productversion, ProductName
复制代码
This actually replaces (-ExpandProperty) the original FileInfo object with the VersionInfo object found within. You basically exchange one object for another one, and lose access to the information held in the first. For example, you no longer have access to properties like LastWriteTime.

If you'd rather want to keep the original FileInfo object, but add some additional information from inside, use Add-Member like this:
  1. Get-ChildItem c:\windows\system32\*.dll |
  2.   Add-Member -MemberType ScriptProperty -Name Version -Value {
  3.   $this.VersionInfo.ProductVersion
  4.   } -PassThru |
  5.   Select-Object -Property LastWriteTime, Length, Name, Version |
  6.   Out-GridView
复制代码
"$this" is the object you are extending.

http://powershell.com/cs/blogs/tips/archive/2013/12/04/getting-dll-file-version-info.aspx

评分

参与人数 1技术 +1 收起 理由
我来了 + 1 还得感谢啊。

查看全部评分

发表于 2017-8-18 09:36:20 | 显示全部楼层
  1. (Get-ChildItem 'C:\Windows\System32\version.dll' | Select-Object -ExpandProperty VersionInfo).ProductVersion
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-17 04:50 , Processed in 0.018227 second(s), 9 queries , File On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表