Access denied to Powershell.exe

We are randomly receiving an access is denied when attempting to execute powershell.exe. There hasn’t been any observed consistency in the product or step, just that it happens with powershell.exe.

Deploying package: D:\Octopus\Files<product>@@.nupkg

May 15th 2019 12:06:48

Info

Transforming ‘D:\Octopus\Applications\Release<product><version>\Web.config’ using ‘D:\Octopus\Applications\Release<product><version>\Web.Release.config’.

May 15th 2019 12:06:49

Error

System.Exception: Error when attempting to execute C:\Windows\system32\WindowsPowershell\v1.0\PowerShell.exe: Access is denied —> System.ComponentModel.Win32Exception: Access is denied

May 15th 2019 12:06:49

Error

at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)

May 15th 2019 12:06:49

Error

at Calamari.Integration.Processes.SilentProcessRunner.ExecuteCommand(String executable, String arguments, String workingDirectory, Dictionary2 environmentVars, String userName, SecureString password, Action1 output, Action`1 error)

May 15th 2019 12:06:49

Error

— End of inner exception stack trace —

May 15th 2019 12:06:49

Error

at Calamari.Integration.Processes.SilentProcessRunner.ExecuteCommand(String executable, String arguments, String workingDirectory, Dictionary2 environmentVars, String userName, SecureString password, Action1 output, Action`1 error)

May 15th 2019 12:06:49

Error

at Calamari.Integration.Processes.CommandLineRunner.Execute(CommandLineInvocation invocation)

May 15th 2019 12:06:49

Error

The command that caused the exception was: “C:\Windows\system32\WindowsPowershell\v1.0\PowerShell.exe” -NoLogo -NonInteractive -ExecutionPolicy Unrestricted -Command “Try {. {. ‘D:\Octopus\Applications\Release<product><version>\Bootstrap.Octopus.Features.IISWebSite_BeforePostDeploy.ps1’ -OctopusKey ‘==’; if ((test-path variable:global:lastexitcode)) { exit $LastExitCode }};} catch { throw }”

May 15th 2019 12:06:49

Error

Script ‘D:\Octopus\Applications\Release<product><version>\Octopus.Features.IISWebSite_BeforePostDeploy.ps1’ returned non-zero exit code: -1

Hi Marshall,

Thanks for getting in touch! I’m sorry to hear you’re hitting this confusing issue. I’ve seen some issues like this in the past where a virus scanner prevents access to PowerShell. Is that a possible explanation in your scenario?

Let me know how you go or if you have any further questions going forward. :slight_smile:

Best regards,

Kenny

To follow up for others seeing similar issues, we tried white-listing just powershell.exe, then increased the scope to the entire C:\Windows\system32\WindowsPowershell\v1.0\ directory, but still experienced the problem occasionally. Now we are disabling the AV during deployments.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.