gpt4 book ai didi

powershell-2.0 - New-PSDrive 不支持凭据?

转载 作者:行者123 更新时间:2023-12-04 10:53:00 27 4
gpt4 key购买 nike

我正在尝试在 PowerShell 2.0 中映射驱动器并收到此错误?

New-PSDrive –Name ftp –PSProvider FileSystem –Root “\\server\folder” -Credential $credential
The provider does not support the use of credentials. Perform the operation again without specifying credentials.

然而, Get-Help New-PSDrive显示 -Credential作为一个有效的选择?

这是PS版本的问题吗?
有没有其他方法可以做同样的事情......我更愿意将它保留在 PS 中(因为驱动器只是 PS)而不是退出 NET USE - NET USE /d但需要必须!

最佳答案

这是一个 bug in PowerShell 2.0

上面链接的解决方法:

$net = new-object -ComObject WScript.Network
$net.MapNetworkDrive("u:", "\\server\share", $false, "domain\user", "password")

据说在 3.0 中修复了(我自己没有测试过)。

关于powershell-2.0 - New-PSDrive 不支持凭据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17036912/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com