除非已通过 Windows 资源管理器打开,否则无法打开共享点 UNC 路径 [英] Cannot open sharepoint UNC path unless already opened through Windows Explorer

查看:110
本文介绍了除非已通过 Windows 资源管理器打开,否则无法打开共享点 UNC 路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望有人能阐明这一点,因为它一直让我分心.

我有一个脚本,它会通过 UNC 路径将它创建的报告保存到共享点文档库(如果路径存在),否则它会保存到网络驱动器位置的 UNC 路径作为后备.

我注意到使用 test-path 进行检查、保存(通过 msexcel COM 对象)或尝试仅使用 invoke-item 在 Windows 资源管理器中打开文件夹如果自 PC 上次登录(我运行的是 Windows 7 Enterprise Service Pack 1 - 64 位版本)以来,我已经访问了 sharepoint 站点(通过网络浏览器 Windows资源管理器),则可以正常工作.>

如果自上次登录后我还没有手动访问过共享点,test-path 返回 false,其他方法会导致 ItemNotFoundException 例如

ii : 找不到路径\\uk.sharepoint.mydomain.local\sites\mycompany\myteam\Shared Documents\Reports",因为它不存在.在行:1 字符:1+ ii '\\uk.sharepoint.mydomain.local\sites\mycompany\myteam\Shared Document ...+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo : ObjectNotFound: (\\uk.sharepoint...\Reports:String) [Invoke-Item], ItemNotFoundException+ FullQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.InvokeItemCommand

示例代码区域:

$LANPath = "\\myserver\myshare\teamdirs\scriptdir"$SharepointPath = "\\uk.sharepoint.mydomain.local\sites\mycompany\myteam\Shared Documents\Reoprts"$ScriptPath = $LANPath + "\bin"If (Test-Path $SharepointPath) {$BasePath = $SharepointPath;write-host "Using sharepoint to save reports"} else {$BasePath = "$LANPath\Reports";write-host "Using LAN to save reports - sharepoint not无障碍"}

$_|select -expandproperty HTMLBody |外文件 $($BasePath + "\Eml_body.html")编写主机重新格式化 HTML"$html = New-Object -ComObject "HTMLFile";$source = Get-Content -Path ($BasePath + "\Eml_body.html") -Raw;

以及从我的 COM 对象中保存 Excel 电子表格时:

$workbook._SaveAs($fileout,[Microsoft.Office.Interop.Excel.XlFileFormat]::xlOpenXMLWorkbook,$Missing,$Missing,$false,$false,[Microsoft.Office.Interop.Excel.XlSaveAsAccessMode]::xlNoChange,[Microsoft.Office.Interop.Excel.XlSaveConflictResolution]::xlLocalSessionChanges,$true,$Missing,$Missing)

解决方案

我知道这是一个旧线程,但对于那些正在搜索的人,请查看此链接:https://www.myotherpcisacloud.com/post/Sometimes-I-Can-Access-the-WebDAV-Share-Sometimes-I-Cant!

由于 SharePoint 通过 WebDav 公开其共享,因此您需要确保 WebClient 服务正在您访问路径的计算机上运行.在资源管理器中浏览路径会自动启动服务,而命令行方法则不会.

如果您将 WebClient 的启动类型更改为自动,应该可以解决问题.

I'm hoping somebody can shed light on this, because it has been driving me to distraction.

I have a script which will save the reports it creates to a sharepoint document library via UNC path, if the path exists, otherwise it saves to the UNC path of a network drive location as a fallback.

I've noticed that checking with test-path, saving (through an msexcel COM object) or trying to open the folder in windows explorer using invoke-item only work if I had already accessed the sharepoint site (via web browser or windows explorer) since the PC last logged on (I'm running Windows 7 Enterprise Service Pack 1 - 64-bit edition).

If I haven't yet been on to sharepoint manually since last logon, test-path returns false, and the other methods cause ItemNotFoundException e.g.

ii : Cannot find path '\\uk.sharepoint.mydomain.local\sites\mycompany\myteam\Shared Documents\Reports' because it does not exist.
At line:1 char:1
+ ii '\\uk.sharepoint.mydomain.local\sites\mycompany\myteam\Shared Document ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (\\uk.sharepoint...\Reports:String) [Invoke-Item], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.InvokeItemCommand

Example areas of code:

$LANPath = "\\myserver\myshare\teamdirs\scriptdir"
$SharepointPath = "\\uk.sharepoint.mydomain.local\sites\mycompany\myteam\Shared Documents\Reoprts"
$ScriptPath = $LANPath + "\bin"
If (Test-Path $SharepointPath) {$BasePath = $SharepointPath;write-host "Using sharepoint to save reports"} else {$BasePath = "$LANPath\Reports";write-host "Using LAN to save reports - sharepoint not accessible"}

and

$_|select -expandproperty HTMLBody | Out-File $($BasePath + "\Eml_body.html")
    Write-Host "Reformating HTML"
    $html = New-Object -ComObject "HTMLFile";
    $source = Get-Content -Path ($BasePath + "\Eml_body.html") -Raw;

and when saving the excel spreadsheet from within my COM object:

$workbook._SaveAs($fileout,[Microsoft.Office.Interop.Excel.XlFileFormat]::xlOpenXMLWorkbook,$Missing,$Missing,$false,$false,[Microsoft.Office.Interop.Excel.XlSaveAsAccessMode]::xlNoChange,[Microsoft.Office.Interop.Excel.XlSaveConflictResolution]::xlLocalSessionChanges,$true,$Missing,$Missing)

解决方案

I know this is an old thread but for those searching, check out this link: https://www.myotherpcisacloud.com/post/Sometimes-I-Can-Access-the-WebDAV-Share-Sometimes-I-Cant!

Because SharePoint exposes its shares over WebDav, you need to ensure the WebClient service is running on the machine from which you are accessing the path. Browsing the path in explorer automatically fires up the service, while command-line methods do not.

If you change the startup type of WebClient to Automatic, it should resolve the issue.

这篇关于除非已通过 Windows 资源管理器打开,否则无法打开共享点 UNC 路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆