I need a PowerShell (v2) script to read or copy files from a SharePoint library resident on a remote SharePoint server. The twist is, I need to filter on the last modified date of the file(s). Also, the server running the script does not have SharePoint installed.
Here's what I've tried:
Get-ChildItem
using the UNC path of the SP file with LastWriteTime filter. I encountered latency issues with this. It runs fine if I've recently opened the document library in the web. But when scheduled to run on its own, the read consistently fails (cannot find file).Copying the files with the script below. Problem is that the modified date is lost when it's copied to the target machine. The date added/modified is now the copy date.
$target = "http://myspweb.com/myfile.xlsx" $dest = "D:\library\newfile.xlsx" $wc = New-Object System.Net.WebClient $wc.UseDefaultCredentials = $true $wc.DownloadFile($target, $dest)
Using the Get-SPWeb command. Allegedly, this exposes properties of the files, including last modified date, but seems to require that the server running the script have SharePoint installed (Add-PSSnapin Microsoft.Sharepoint.Powershell gives a "not installed on this machine" error.) A full SharePoint installation isn't really an option -- nor is remoting. Some installation of SP tools might be an option, but I can't figure out what would be required.
Any other ways to approach this?