0
我遇到了使用New-PSDrive
连接到远程服务器的问题。远程服务器是基于Windows的,并且只有userA
才有权写入。New-PSDrive:未找到网络路径
通过说,下面的代码会抛出一个“拒绝访问”错误:
Access to the path '$remoteServerPath' is denied on line3
代码:
New-PSDrive -Name remote -Root $remoteServerPath -PSProvider FileSystem
$destination = [IO.Path]::Combine('remote:', $fileName)
Copy-Item -Path $source -Destination $destination -Force
现在,我想包括凭据信息,但我得到一个不同的错误!
The network path was not found on line3
$secpass = ConvertTo-SecureString 'myPassword' -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential ('domain\userA', $secpass)
New-PSDrive -Name remote -Root $remoteServerPath-PSProvider FileSystem -Credential $cred
$destination = [IO.Path]::Combine('remote:', $fileName)
Copy-Item -Path $source -Destination $destination -Force
任何人都可以请帮我吗? Powershell Ver。 5
我收到以下错误: “文件系统提供程序只支持在新PSDrive来cmdlet的凭据没有 指定凭据重新进行操作。” – Adrian
@Adrian使用这个例子逐字? – TheIncorrigible1
看起来只有New-PSDrive支持凭证,而复制项目不支持。是因为我的PS版吗? (5) – Adrian