PowerShell Copy-Item 在 Octopus 中给出错误

标签 powershell octopus-deploy

我尝试将 DLL 文件从我的计算机复制到另一台计算机并注册它:

net use \\RemoteIp\C$\Dev 'pass'/USER:'user'  

复制项“D:\test.dll”-目标“\\RemoteIp\c$\Dev”;

regsvr32 "\\RemoteIp\C$\Dev\test.dll"

我遇到的问题是,当我尝试从 Octopus 运行此脚本时,我收到此错误:

Copy-Item : Cannot find path 'D:\test.dll' because it does not exist. At C:\Octopus\Work\20160606100457-74\Script.ps1:3 char:10 + copy-item <<<< "D:\test.dll" -Destination "\RemoteIp\c$\Dev"; + CategoryInfo : ObjectNotFound: (D:\test.dll :String) [Copy-Item], ItemNotFoundException + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.CopyI temCommand The remote script failed with exit code 1

如果我尝试在 PowerShell 中运行这些代码行,它会正常工作。

有什么建议吗?

谢谢

最佳答案

其实这是我的错。当您在 Octopus 中运行旨在在部署目标上运行的脚本时:1]

您必须使用 IP 地址定义您的本地电脑。例如,在我的例子中,我必须像这样编写地址“D:\test.dll”:“\192.168.00.00\D$\test.dll”。

对于 regsvr32 问题,我在运行 regsvr32 指令的服务器上添加了一个 bat 文件,我只需调用该文件,它就会完成其余的工作。

希望对其他人有帮助:)

关于PowerShell Copy-Item 在 Octopus 中给出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37654852/

相关文章:

azure - 为什么我可以在 Visual Studio 之外运行此 Azure 资源组部署脚本?

excel - 将哈希表导出为 CSV,并将键作为列标题

powershell - 更改 Windows PowerShell 中的路径分隔符

xml - 如何在 XML 配置文件中指定 Octopus 内置变量名?

octopus-deploy - 无法在提要中下载包 : Could not find package . ..

windows - 在 Windows dockerfile 中转义美元符号

regex - 将长正则表达式拆分为多行?

sql-server - 如果尚未安装,仅安装 PowerShell PackageProvider 和 Module

c# - 八达通客户端,从C#中的项目名称获取版本