UnauthorizedAccessException

I have a step which executes some very simple powershell but I get the error “UnauthorizedAccessException”.

I’ve :
restarted the box,
given the service account specific admin access on that drive (even though it is already in the admin group)

One thing I really don’t understand is the Y:\work\14ffc968155e4956\source\Calamari\Integration\Scripting\WindowsPowerShell\PowerShellBootstrapper.cs:line bit, I don’t have a Y: drive on this box

D:\Octopus\Work\20160704084546-34\Bootstrap.ps1
09:45:51Error
System.UnauthorizedAccessException: Access to the path 'D:\Octopus\Work\20160704084546-34\Bootstrap.Script.ps1' is denied.
09:45:51Error
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
09:45:51Error
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
09:45:51Error
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
09:45:51Error
   at System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost)
09:45:51Error
   at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost)
09:45:51Error
   at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding)
09:45:51Error
   at Calamari.Integration.Scripting.WindowsPowerShell.PowerShellBootstrapper.PrepareBootstrapFile(String targetScriptFile, CalamariVariableDictionary variables) in Y:\work\14ffc968155e4956\source\Calamari\Integration\Scripting\WindowsPowerShell\PowerShellBootstrapper.cs:line 73
09:45:51Error
   at Calamari.Integration.Scripting.WindowsPowerShell.PowerShellScriptEngine.Execute(String scriptFile, CalamariVariableDictionary variables, ICommandLineRunner commandLineRunner) in Y:\work\14ffc968155e4956\source\Calamari\Integration\Scripting\WindowsPowerShell\PowerShellScriptEngine.cs:line 19
09:45:51Error
   at Calamari.Commands.RunScriptCommand.InvokeScript(CalamariVariableDictionary variables) in Y:\work\14ffc968155e4956\source\Calamari\Commands\RunScriptCommand.cs:line 80
09:45:51Error
   at Calamari.Program.Execute(String[] args) in Y:\work\14ffc968155e4956\source\Calamari\Program.cs:line 38
09:45:52Error
System.UnauthorizedAccessException: Access to the path 'D:\Octopus\Work\20160704084546-34\Bootstrap.Script.ps1' is denied.
09:45:52Error
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
09:45:52Error
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
09:45:52Error
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
09:45:52Error
   at System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost)
09:45:52Error
   at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost)
09:45:52Error
   at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding)
09:45:52Error
   at Calamari.Integration.Scripting.WindowsPowerShell.PowerShellBootstrapper.PrepareBootstrapFile(String targetScriptFile, CalamariVariableDictionary variables) in Y:\work\14ffc968155e4956\source\Calamari\Integration\Scripting\WindowsPowerShell\PowerShellBootstrapper.cs:line 73
09:45:52Error
   at Calamari.Integration.Scripting.WindowsPowerShell.PowerShellScriptEngine.Execute(String scriptFile, CalamariVariableDictionary variables, ICommandLineRunner commandLineRunner) in Y:\work\14ffc968155e4956\source\Calamari\Integration\Scripting\WindowsPowerShell\PowerShellScriptEngine.cs:line 19
09:45:52Error
   at Calamari.Commands.RunScriptCommand.InvokeScript(CalamariVariableDictionary variables) in Y:\work\14ffc968155e4956\source\Calamari\Commands\RunScriptCommand.cs:line 80
09:45:52Error
   at Calamari.Program.Execute(String[] args) in Y:\work\14ffc968155e4956\source\Calamari\Program.cs:line 38
09:45:53Error
System.UnauthorizedAccessException: Access to the path 'D:\Octopus\Work\20160704084546-34\Bootstrap.Script.ps1' is denied.
09:45:53Error
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
09:45:53Error
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
09:45:53Error
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)```

Hi Chris,

Thanks for reaching out!

So yeah that error means that the account taking the action (the one running the Tentacle Service) doesn’t have access to that path under D:\. Are you sure this account has access to the entire drive or at least to D:\Octopus and below?

Additionally we introduced a fix to handle these boostrap.ps1 file lock situation a bit better in 3.3.20. If possible, try to upgrade to this version and let me know if that helps.

Best regards,
Dalmiro