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:- Get-ChildItem c:\windows\system32\*.dll |
- Select-Object -ExpandProperty VersionInfo |
- 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:- Get-ChildItem c:\windows\system32\*.dll |
- Add-Member -MemberType ScriptProperty -Name Version -Value {
- $this.VersionInfo.ProductVersion
- } -PassThru |
- Select-Object -Property LastWriteTime, Length, Name, Version |
- 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 |