I can not display the modification date of a directory with powershell

0
Hello, I'm trying to display the date of creation and modification of a directory using powershell, I'm using the command:

Get-WmiObject Win32_Directory -filter 'Drive="C:" and Path="\"' -ComputerName MyPC |
select FileName,LastModified -First 3

But the return I have is a string:

FileName                         LastModified             
--------                         ------------             
$recycle.bin                     20151022091602.219458-120
0f74e86e50f02a5493eece53fbe1da58 20141005215102.861881-180
384d408957a87176de               20141004215102.325431-180

How do I display the date or to convert these string into date?

    
asked by anonymous 18.11.2015 / 14:21

2 answers

0

I got the information I wanted by formatting the output generated with the following code:

Get-WmiObject Win32_Directory -filter 'Drive="D:" and Path="\users\"' -ComputerName $HostName | sort LastModified -Descending | select -First 3 | foreach{
   $newObj = "" | select Name,LastModified,hostname
   $newObj.Name = $_.Name
   $newObj.LastModified = $_.LastModified.Substring(0,8).Insert(4,"/").Insert(7,"/")
   $newObj.hostname = $HostName

   $newObj
}
    
28.01.2016 / 16:38
0

You can use Get-ItemProperty. Ex:

(Get-ItemProperty C:\Temp).CreationTime
Monday, March 30, 2015 8:15:55 PM

(Get-ItemProperty C:\Temp).LastWriteTime
Thursday, January 7, 2016 17:56:06

    
07.01.2016 / 21:11