I am having an issue with updating an action associated with a scheduled task.
I want to set the actions execute property to the new file location of the executable from the new deployment.
I need all scheduled tasks in the path ‘Example_task_path’ to change the executable that it triggers to the newly deployed version
When running the following PowerShell script from the Custom Deployment Scripts section of a Deploy a package step, the script runs but never completes.
When running through Windows PowerShell ISE on the server as administrator the script runs fine all the way through.
When run without administrator rights it hits User Account Control prompt.
OK, is your Tentacle running under an account that is not a local administrator on the server? This would cause the script to prompt for UAC when run and this would of course hang the task in Octopus.
Essentially It cannot find any Scheduled Tasks in the given TaskPath if it’s not run as an administrator
As far as I can tell it should be running with administrator rights so I tried to elevate the admin rights to run the script which is where I am now having issues
My sincere apologies for the delay in getting back to you, the notification seems to have fallen through the cracks and I did not see it.
Starting a new powershell process with elevated rights won’t work when running a script on the Tentacle.
Looking at the error that you got ForEach-Object : Cannot validate argument on parameter ‘User’. The argument is null or empty. Provide an argument that, it seems to point to Set-ScheduledTask call is the source of the error as it’s complaining about the User parameter.
Could it be that the $OctopusParameters["SpecificUsername"] variable isn’t set correctly?
Through various iterations of attempts to find an answer I have just managed to successfully deploy!
One of the issues was with my powershell and was nothing to do with octopus at all! Set-ScheduledTask requires a -TaskName parameter apparently that was missing from the code above.
I’m still not sure why it wasn’t working previously, as all the code I ran through octopus I had tested direct on the server first and they were functioning correctly.