How to download newest file from SharePoint using PowerShell

大城市里の小女人 提交于 2019-12-23 04:33:53

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!