该CreationTime属性已包含一个DateTime对象,因此您只需展开该属性:
CreationTime
DateTime
$tmpCreated = Get-ChildItem | Sort-Object CreationTime -Descending | Select-Object -Expand CreationTime -First 1 $timeDiff = New-TimeSpan –Start $tmpLast –End $tmpCreated