PowerShell映射持久sharepoint路径

PowerShell映射持久sharepoint路径,powershell,sharepoint,mapping,Powershell,Sharepoint,Mapping,我正在尝试以持久的方式将路径映射到SharePoint文档库。奇怪的是,这样做效果很好: $Sharepoint = '\\domain.net\stuff\Documents\Folders - Permission matrix' New-PSDrive -Name P -Root $Sharepoint -PSProvider FileSystem -Credential $Credentials 但这不起作用: New-PSDrive -Persist -Name P -Root $S

我正在尝试以持久的方式将路径映射到SharePoint文档库。奇怪的是,这样做效果很好:

$Sharepoint = '\\domain.net\stuff\Documents\Folders - Permission matrix'
New-PSDrive -Name P -Root $Sharepoint -PSProvider FileSystem -Credential $Credentials
但这不起作用:

New-PSDrive -Persist -Name P -Root $Sharepoint -PSProvider FileSystem -Credential $Credentials
New-PSDrive : The network resource type is not correct
At line:1 char:1
+ New-PSDrive -Persist -Name P -Root $Sharepoint -PSProvider FileSystem -Credentia ...

这两个命令都使用相同的
PSProvider
,但一个是持久的,另一个不是。如何在不恢复到
net use
的情况下保持这种持久性?

几周前,我在一个脚本中遇到了这个问题,该脚本在我开发它时神秘地停止了工作,似乎是Windows错误,而不是Powershell错误

这里有一个使用凭据的网络使用的替代方案

# map drive using credentials
(New-Object -ComObject WScript.Network).MapNetworkDrive("$LocalDrive","\\$computer\$drive",$false,$($credentials.username),$($credentials.GetNetworkCredential().password))
我倾向于这样使用PSDrive

    # discover and delete
    if (Get-PSDrive -Name Results -ErrorAction SilentlyContinue) { Remove-PSDrive -Name Results -Scope Global | Out-Null }

    # create using credentials
    if ((New-PSDrive -Name Results -PSProvider FileSystem -Root "\\server\share" -Credential $Credentials -Scope Global -ErrorAction SilentlyContinue) -eq $null)  { $WSHShell.popup(“You do not have access to the results repository“,0,””,0) | Out-Null }

    # call from a separate function
    (Get-PSDrive -Name Results).root

重新启动可能会解决问题,因为我今天无法重新创建该问题。

我遇到了一个类似的问题,Windows 2016和2019需要安装WEBDav重定向,我在尝试映射sharepoint库时遇到错误53。

有趣,我可以复制,而且必须强调这没有任何意义在我的情况下(Windows 7,PowerShell 4.0)无法复制。您仍然有问题吗?你回答的措辞有点模棱两可。