Slowness with PowerShell Compress-Archive command


I’m noticing a performance hit when I run the following PowerShell command in Octopus:

        $stopwatch = [Diagnostics.Stopwatch]::StartNew()
        Compress-Archive -Path $source -DestinationPath $destination -Force -CompressionLevel Fastest
        Write-Output "Compression completed in $($stopwatch.Elapsed)"

When I run this PowerShell command natively in the deploy target, it runs in 2 minutes.

When running this as a step in Octopus deploy the same command for the same folders takes 8 minutes.

For lack of a better speculation, I’m thinking It could be the priority the tentacle runs under (likely lower priority than my native user session). Have you seen this before, and would you have any ideas as to why this is happening… and any potential ways to make this run faster via Octopus?


Hi Jafar,

Thank you for getting in touch. We havn’t seen something specifically like this before, I assume you mean the 8 minutes is the output of the stopwatch, not the whole deployment run time?

Since the scripts are not run in an interactive session, Windows may be deprioritising them.

You could try not loading the powershell profile by setting the Octopus.Action.PowerShell.ExecuteWithoutProfile project variable to true.

Robert W