我想使用Powershell从sharepoint下载excel文件。我正在尝试下面的代码,但不幸的是它无法正常工作。
$fromfile = "https://test.sharepoint.com/test.xlsx"
$tofile = "c:\Script\new.xlsx"
$webclient = New-Object System.Net.WebClient
$webclient.UseDefaultCredentials = $true
$webclient.DownloadFile($fromfile, $tofile)
谢谢
答案 0 :(得分:0)
某些服务器需要User-Agent
标头。在最后一行之前添加:
$webclient.Headers.Add("User-Agent: Other");