运行powershell cmd复制文件并运行

问题描述 投票:0回答:1

所以我习惯了运行批处理脚本和使用命令提示符,但我正在尝试切换到 Powershell。我正在尝试将文件从我的电脑复制到网络上的另一台计算机并执行

psexec \RemoteComputer -s powershell.exe -command "Copy-Item -Path 'C:\Path\To\Your\File.txt' -Destination 'C:\Destination\Path'"

我希望它能够提供在继续执行流程之前输入目标计算机 IP 的选项

powershell copy domain-driven-design admin execute
1个回答
0
投票

您的问题的答案包含在官方文档的示例5中:

$Session = New-PSSession -ComputerName "RemoteComputer" -Credential "RemoteUser"
Copy-Item "C:\Path\To\Your\File.txt" -Destination "C:\Destination\Path" -ToSession $Session

您还可以看到其他示例,例如递归复制。

© www.soinside.com 2019 - 2024. All rights reserved.