问题
I'm just curious, do I have any possibility to download the file from SharePoint document library?
The problem is that I have like 3-4 files in this library and I need to get the file with the latest modification date.
Thank you in advance.
回答1:
Refer to the link below, but instead of using the actual SharePoint URL for the directory use the File Explorer address for the SharePoint site.
Powershell Script:
$dir = "\\sharepoint.domain.com\site\Foo\SubFoo\SharedDocuments\Folder\"
$latest = Get-ChildItem -Path $dir | Sort-Object LastAccessTime -Descending | Select-Object -First 1
$latest.name
To get the explorer location, right click on a file link in SharePoint, (Firefox 'Copy link location', IE 'Properties').
Copy the URL: http://sharepoint.domain.com/site/Foo/SubFoo/SharedDocuments/Folder/
Change it this format: \\sharepoint.domain.com\site\Foo\SubFoo\SharedDocuments\Folder\
Verify the link works: Click 'Start' --> 'Run' --> paste the changed link and run it. It should open the SharePoint folder.
The PowerShell code came from this site.
Give them a check too:
How to find newest file in directory using PowerShell script?
来源:https://stackoverflow.com/questions/28946557/how-to-download-newest-file-from-sharepoint-using-powershell