我正在尝试运行批处理文件将文件从远程计算机(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