Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

One way to extract the lastwritetime from files located on different shared drives is to use a PowerShell script. The script would need to loop through the shared drives and folders, and then use the Get-ChildItem cmdlet to retrieve the files and their lastwritetime property.

Here is an example script:

$sharedDrives = "\\server1\share1", "\\server2\share2", "\\server3\share3"

foreach ($share in $sharedDrives) {
    $files = Get-ChildItem -Path $share -Recurse | Where-Object { $_.PSIsContainer -eq $false }

    foreach ($file in $files) {
        $lastWriteTime = $file.LastWriteTime
        Write-Host "File: $($file.FullName) Last Write Time: $lastWriteTime"
    }
}

This script first defines the shared drives as an array of strings. The script then loops through each shared drive and retrieves all files (not directories) within that share using the Get-ChildItem cmdlet with the -Recurse parameter. It then loops through each file and retrieves its lastwritetime property, and outputs the file name and last write time to the console using the Write-Host cmdlet.

Note that the user running the script will need appropriate permissions to access the shared drives and files.