Ujjwal Singh
Ujjwal Singh

Reputation: 4988

Get LastWriteTime of SymLink's Target

(Get-Item $SymLink).LastWriteTime return's the SymLink's last modified time and not the target's modified time.

How do I get the target's last modified time?

Upvotes: 1

Views: 204

Answers (1)

Ujjwal Singh
Ujjwal Singh

Reputation: 4988

There appears to be no direct way, thus for now this will have to be done in two steps-

  1. Get the path of the SymLink's target
  2. Get the LastWriteTime from the target's path

To determine if its a symlink: Check if SymLink - PowerShell
To get the path:

  1. use the Dir command's summary output - from which the target information can be snipped out - using RegEx.
  2. or using Native API Call: GetFinalPathNameByHandle; see: Calling Unmanaged Code from PS

Upvotes: 1

Related Questions