I am trying to output file creation time with milliseconds using PowerShell.
This works but only outputs seconds:
Get-ChildItem *_971*.* -Force | Select-Object FullName, CreationTime
If I try to format the timestamp like this:
Get-ChildItem *_971*.* -Force | Select-Object FullName, CreationTime.ToString('yyyyMMdd HH:mm:ss.fff')
I get an error:
Select-Object : A positional parameter cannot be found that accepts argument 'yyyyMMdd HH:mm:ss.fff'.
At line:1 char:33
You need to use a calculated property to evaluate the expression CreationTime.ToString('yyyyMMdd HH:mm:ss.fff')
over each pipeline item:
Get-ChildItem *_971*.* -Force |
Select-Object FullName, @{ N='CreationTime'; E= { $_.CreationTime.ToString('yyyyMMdd HH:mm:ss.fff') }}