PowerShell New-PSDrive无法使用身份验证

时间:2015-04-16 09:41:57

标签: powershell

我正在尝试将SharePoint文档库映射为字母Z.将Windows资源管理器中的驱动器映射为“映射网络驱动器”并提供凭据可以正常工作。

但是如何在PowerShell中映射此驱动器并且不使用Windows资源管理器GUI步骤进行身份验证?

我尝试使用-Credential的{​​{1}}开关,但PowerShell却抱怨找不到驱动器......

代码:

New-PSDrive

错误:

$Sharepoint = 'http://My site/Documents/Folders - Permission matrix'
New-PSDrive -Name Z -PSProvider FileSystem -Root $Sharepoint -Credential $Credential

感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

我认为您的语法对New-PSDrive无效。 FileSystem Provider不包含使用http前缀指定的元素。

您应该使用\\My site\Documents\Folders - Permission matrix作为New-PSDrive的输入,因为FileSystem提供程序接受UNC路径。