Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

In PowerShell, Get/Set timestamps on Reparse Points are inconsistent - bug or feature?

$
0
0

If I read the CreationTime property (or other timestamps) on a Reparse Point I get the CreationTime for the Reparse Point; but if I write it, the target is updated, not the Reparse Point. Is this a known problem? I've put it on MS Connect but had no interest as yet.

A PowerShell script to demonstrate it:

$tgt = new-object -typename System.IO.DirectoryInfo -args C:\DirTarget
if (!$tgt.exists) {
  $tgt.create()
  $tgt.refresh()
}
$jct = new-object -typename System.IO.DirectoryInfo -args C:\Junct
if (!$jct.exists) {
  # make sure creation time is later:
  sleep 2
  cmd.exe /c "mklink /j C:\Junct C:\DirTarget"
  $jct.refresh()
}

write-host ("CreationTime of C:\DirTarget is " + $tgt.creationtime)
write-host ("CreationTime of C:\Junct is " + $jct.creationtime)

# make sure new  creation time is different:
sleep 2
$newTime = get-date
write-host ("Setting CreationTime on C:\Junct to " + $newTime)
$jct.creationtime = $newTime

$jct.refresh()
write-host ("Now CreationTime of C:\Junct is still " + $jct.creationtime)
$tgt.refresh()
write-host ("but CreationTime of C:\DirTarget is " + $tgt.creationtime)

It makes no difference if you use (get-item C:\Junct).creationtime etc. instead of $jct, $tgt.


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>