Search code examples
powershelloctopus-deploy

PowerShell Copy-Item gives error in Octopus


I try to copy a DLL file from my computer to another and register it:

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

copy-item "D:\test.dll" -Destination "\\RemoteIp\c$\Dev";

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

The problem that I have is that when I try to run this script from Octopus I receive this error :

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

If I try to run these lines of code in PowerShell it works properly.

Any suggestions ?

Thank you


Solution

  • Actually this was my fault. When you are running a script in Octopus that is meant to run on the Deployment target: 1]

    you have to define your local pc with the ip address. For example, in my case I had to write the address "D:\test.dll" like this : "\192.168.00.00\D$\test.dll" .

    For the regsvr32 problem, I added a bat file on the server that runs the regsvr32 instruction and I just call that file and it does the rest.

    Hopefully that helps others :)