Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Get File time stamp and calculate

$
0
0

Hi all

Each computer in a specific area writes a log to the network once every 30 minutes. the log directory is the computer name and a single file called log.txt I am trying to get the time the folder was created and the last time the log was written, if the new-timespan is greater than 30 minutes, export to file or show on the screen

Running
Logged = (Get-ChildItem -Path "C:\watchdog\logs$" Recurse -Include "log.txt"| select Name, astaccesstime, lastWriteTime)
$t1 = ($Logged).LastWriteTime
$t2 = ($Logged).LastAccesstime
$t1
$t2
$Logged

Gives me

$Name           : log.txt
LastAccessTime : 8/13/2013 3:13:55 PM
LastWriteTime  : 8/13/2013 3:14:09 PM

Name           : log.txt
LastAccessTime : 8/13/2013 2:36:14 PM
LastWriteTime  : 8/13/2013 3:03:05 PM

But I want to to level directory so i know which computer it is.

How tdo I achieve that?


Viewing all articles
Browse latest Browse all 6937

Trending Articles