1

I have setup an Octopus deployment script to update SharePoint solutions using Update-SPSolution and WSP packages.

  • When I test the script from Powershell ISE (run as Administrator), it works.
  • When I test the script from Powershell ISE (normal mode), it fails with error Update-SPSolution : Access denied
  • When I let it run from Octopus, it also fails with error Update-SPSolution : Access denied

I added the following code to see whether my code runs as Administrator when ran from Octopus:

If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(`
    [Security.Principal.WindowsBuiltInRole] "Administrator"))
    {
        Write-Warning "You do not have Administrator rights to run this script! nPlease re-run this script as an Administrator!"
        Break
    }

It turns out the deployment step is not ran as Administrator when ran by Octopus, although the User of the Octopus Tentacle Service has the rights to run as administrator.

How can I force Octopus to run my script as administrator?

AllWorkNoPlay
  • 454
  • 1
  • 4
  • 20

2 Answers2

2

I had come across the same issue, where the powershell script did not run as administrator and was not able to add/deploy farm solution. It was resolved for me when I changed the account which was running the OctopusDeploy Tentacle service to the farm administrator account. I performed the following steps:

  1. Open services.msc
  2. Find OctopusDeploy Tentacle, and change the log on account to a farm administrator account. Restart the service.
Richardissimo
  • 5,596
  • 2
  • 18
  • 36
snehankita
  • 21
  • 2
0

Have you tried using the SharePoint step template available in the library? https://library.octopusdeploy.com/step-templates/7ac03a43-cb18-4e83-a114-b158a2bb2a52/actiontemplate-sharepoint-solution-deployment

PS: I'm unable to add comment, hence using this box to respond to your question.

Hope this help.

Jasmin

Jasmin
  • 36
  • 4
  • My step is a customization of this step template. It requires the Local Service to be Farm administrator, I am not comfortable to do this, – AllWorkNoPlay May 31 '17 at 14:21