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?