Collecting artifacts with powershell - what am I doing wrong?

This seems so straight forward that I have to assume I’m just completely overlooking something.

I deploy a package that runs a process that results in a log file. We’ll say the directory it logs to is C:\snoop and the log file is called loggy.log

The final step in the deployment process is a one-line powershell script that is supposed to collect this log. The command is:
New-OctopusArtifact -Path “c:\snoop” -Name “loggy.log”

When I run this step I get the following error message in my OD server:
Collecting artifact loggy.log
Artifact loggy.log not found at path 'C:\snoop. This can happen if the file is deleted before the task completes.

I know the tentacle has access to this location because a normal deployment logs to that location. I know it’s not contention/locking because I’ve moved the file in place manually and run the step independently.

Any thoughts on where to go from here?

Hi Jeffrey,

Thanks for getting in touch! The path needs to include the filename of the file you wish to be the artifact. The name simply gives it a nice name in Octopus.

Hope that helps!
Vanessa

I had this problem too when reproducing the Octopus documentation:
New-OctopusArtifact -Path “C:\Windows\System32\drivers\etc\hosts” -Name “$([System.Environment]::MachineName)-hosts.txt”

Your suggestion solved the problem.