I am using Powershell version 3 at the moment. (but this may need to run in powershell version 2 as well).
Trying to get versioninfo to show the FileName, FileVersion, ProductVersion across a directory recursively.
but I also want the creationtime (or maybe in the future other properties to show).
While you can only use -expandproperty on 1 entity, i thought we could combine
it with -property and choose others. The results to return, but no ‘creationtime’ is shown.
It’s as if it’s being ignored.
I searched and I think my answer may lie with a custom psobject? Any hints would be great.
See my example code below.
You want a custom property. Maybe several. You can’t use -Property and -Expand at the same time. Honestly, I’m a little surprised the cmdlet isn’t wired to complain about that.
You need to make a custom property for each hunk of VersionInfo that you want included. To be clear, there’s no magic, “expand VersionInfo into five properties and attach them all;” you need to do that yourself. I’ve done two pseudo-ones.
I try to do most filtering as early in the pipeline as possible. Here I would use the -file with Get-ChildItem to remove the need for the ‘Where…’ line: