0

I'm using Robocopy's log feature to get file information regardless of folder depth (from Learn-PowerShell).

I was able to get a file's timestamp using /TS option of Robocopy, but this timestamp is modified date of the file. I also need to log the created date.

So how can I log created date of file?

And another one, how to log Modified date and Created date of folder too, using Robocopy?

Thanhma San
  • 1,347
  • 2
  • 8
  • 12
  • Do you actually have files that exceed the 260 char path limitation? if not just use `get-childitem`...Are you using the script you linked or just robocopy? if only robocopy then you need to consider the possibility that robocopy may not have an option to show `modified datetime` – Kiran Reddy Dec 23 '15 at 07:14
  • I am facing 260 char path problem, that's why I have to use robocopy. And I'm using the script in the link, with some modification. – Thanhma San Dec 23 '15 at 08:02
  • Are you open to using tools other than robocopy? also what version of powershell are you running? – Kiran Reddy Dec 24 '15 at 03:28
  • Yes, I can use other tools that fulfill the need (export file/folder name, path, created date, modified date). I'm using PowerShell 4 on Windows 8.1. – Thanhma San Dec 24 '15 at 07:19

1 Answers1

0

if you can find a computer with PowerShell v5 you can install a module called PSAlphaFS .

Install-Module PSAlphaFS

copy the module to your system running powershell 4 and import it.

Import-module PSAlphaFS

then run the following command which is similar to get-childitem but without the 260 char limitation.

Get-LongChildItem -Path C:\temp -Recurse | 
  Select-Object Name,FullName,CreationTime,LastWriteTime
Kiran Reddy
  • 2,836
  • 2
  • 16
  • 20
  • Thank you @Kiran, I'm able to run your `Get-LongChildItem` command on PowerShell 5. But how can I copy and import module to the PC with PowerShell 4? – Thanhma San Dec 25 '15 at 03:00
  • 1
    by default on windows 10 the modules from powershellgallery get installed to `C:\Program Files\WindowsPowerShell\Modules`...so just copy the module from this location to your system (same location or to any of the locations mentioned in `[Environment]::GetEnvironmentVariable("PSModulePath", "Machine")`) thats it... – Kiran Reddy Dec 25 '15 at 06:05
  • Thank you. I also need to move files in 1.0.0.0 folder to outside since the `Import-Module` could not find the script file. One more question, can I use this on PowerShell 3? The `invoke member w/ expression name` error comes out when I try it on PS3. – Thanhma San Dec 25 '15 at 06:36
  • ah i see...didnt know about moving the files anyway good that it is working...when i wrote the module i only tested it on V4 and V5...so i cannot tell if it will work on V3 but since the alphafs library needs .net 4.5 do check if your V3 system is running the latest dot net... – Kiran Reddy Dec 25 '15 at 06:55
  • It is `@($DirObject::$DirType($pItem ,$Filter, [System.IO.SearchOption]::$search_option) )` in `#foreach file & folder` that makes PS 3 unable to run. But adding -File/-Directory switch to the command still run well. And that's enough for my requirement. Thanks for your answer and your module. – Thanhma San Dec 25 '15 at 08:45