我想从一个远程服务器复制到另一个PSSession内的文件夹,它给出错误,如访问被拒绝。我有两个服务器的管理员权限。如果我尝试它没有PSSession它有效。在PowerShell中如何将文件从远程PSsession复制到另一个Windows服务器
在远程serverA的
PS C:\Users\Automation\Documents> [System.Net.Dns]::GetHostName()
sql
PS C:\Users\Automation\Documents> Copy-Item -Path .\abc.csv -Destination "\\jump\c$"
PS C:\Users\Automation\Documents>
在远程serverB上
PS C:\Users\Automation\Documents\sample\SQL Final Scripts> Copy-Item -Path ".\SQL_queries.csv" -Destination "\\sql\c$\"
PS C:\Users\Automation\Documents\sample\SQL Final Scripts> Enter-PSSession -ComputerName sql -Credential "[email protected]"
[sql]: PS C:\Users\Automation\Documents> Copy-Item -Path ".\SQL_queries.csv" -Destination "\\jump\c$\"
Copy-Item : Access to the path '\\jump\c$\' is denied.
+ CategoryInfo : PermissionDenied: (C:\Users\Automa...SQL_queries.csv:FileInfo) [Copy-Item], Unauthorized
AccessException
+ FullyQualifiedErrorId : CopyFileInfoItemUnauthorizedAccessError,Microsoft.PowerShell.Commands.CopyItemCommand
[sql]: PS C:\Users\Automation\Documents>
您所面临的“双跳”的问题。在SQL计算机'Enable-WSManCredSSP -Role Server'上运行这个命令并在服务器B上运行'Enable-WSManCred -Role Client -DelegateComputer *',然后当你进入远程会话时执行Enter-PSSession -ComputerName sql -Authentication Credssp - Credential(Get-Credential)' – 2013-03-19 20:18:20
@BobLobLaw,如果您发布该答案而不是对我的评论,它将有机会被接受为上级答案(在我的上面)。 – alroc 2013-03-19 20:24:26