Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Can';从远程运行带有powershell的批处理文件时,不能使用xcopy复制文件_Powershell_Batch File_Remote Server_Xcopy - Fatal编程技术网

Can';从远程运行带有powershell的批处理文件时,不能使用xcopy复制文件

Can';从远程运行带有powershell的批处理文件时,不能使用xcopy复制文件,powershell,batch-file,remote-server,xcopy,Powershell,Batch File,Remote Server,Xcopy,我正在尝试运行批处理文件以将文件从远程计算机(a)复制到本地计算机(B)-这两台计算机位于一个工作组中,并且彼此具有完全访问权限。我正在从远程计算机(A)运行带有PowerShell脚本的批处理文件。 批处理文件包含以下命令: XCOPY \\buildagent01\C$\agent\_work\2\a\Bin\JobServer \\Automation\C$\QA\VLast\Backend\WinServices\JobServer 如果我在命令提示符下直接从远程或本地计算机运行此XC

我正在尝试运行批处理文件以将文件从远程计算机(a)复制到本地计算机(B)-这两台计算机位于一个工作组中,并且彼此具有完全访问权限。我正在从远程计算机(A)运行带有PowerShell脚本的批处理文件。 批处理文件包含以下命令:

XCOPY \\buildagent01\C$\agent\_work\2\a\Bin\JobServer \\Automation\C$\QA\VLast\Backend\WinServices\JobServer
如果我在命令提示符下直接从远程或本地计算机运行此XCOPY命令-正在复制文件,如果我使用powershell运行包含此命令的批处理文件(Version.bat)-正在复制0个文件。。。 这就是PowerShell的外观:

#Predefine necessary information
$Username = "aaaa"
$Password = "*****"
$ComputerName = "Automation"
$Script = {\\Automation\C$\QA\Version.bat $args[0] $args[1] $args[2] $args[3] $args[4]}

$Binaries_Directory_Path = "\\buildagent01\C$\agent\_work\2\a\Bin\JobServer"
$QA_Fold = "\\Automation\C$\QA"
$Exclude = "\\Automation\C$\QA\Exclude.txt"
$Deployed_version_sufix = "1"
$BackupFoldPrefix = "BackupTo"
$Backup_Fold = $BackupFoldPrefix+$Deployed_version_sufix


#Create credential object
$SecurePassWord = ConvertTo-SecureString -AsPlainText $Password -Force
$Cred = New-Object -TypeName "System.Management.Automation.PSCredential" -ArgumentList $Username, $SecurePassWord

#Create session object with this
$Session = New-PSSession -ComputerName $ComputerName -credential $Cred

#Invoke-Command
$Job = Invoke-Command -Session $Session -Scriptblock $Script -ArgumentList $Binaries_Directory_Path,$QA_Fold,$Backup_Fold,$Exclude,$Deployed_version_sufix
echo $Job

#Close Session
Remove-PSSession -Session $Session

听起来像是个问题。你能帮我解决这个问题吗?读一读我链接到你的阿什利·麦格隆的文章。双跳有很多方法,每种方法都有缺点。但在一两行中改变某些东西并不容易,这是一个架构设计决策。最简单的解决方案是启用
CredSSP
或使用
psexec.exe
而不是
invoke command
,两者都有缺点。@RanadipDutta小心地推荐CredSSP作为解决方案,因为它会带来严重的安全后果。