Thanks for getting in touch. That error often occurs if the script is modifying a part of a step without including all required fields. The best practice when changing steps in this way is:
- Do a GET on your template deployment process and assign that value to a variable
- Modify the values of that variable according to the needs of your new projects
- PUT the modified template on your new project.
The below sample script amends the role on a specific step. Hopefully, it will help provide a starting point for you. You can find other script samples here:
# You can this dll from your Octopus Server/Tentacle installation directory or from
Add-Type -Path 'C:\Program Files\Octopus Deploy\Octopus\Octopus.Client.dll'
$apikey = '<API KEY>' # Get this from your profile
$octopusURI = 'http://localhost' # Your server address
$projectId = "Projects-1" # Get this from /api/projects
$stepName = "Run a script test" # The name of the step
$role = "demo-role" # The machine role to run this step on
$endpoint = New-Object Octopus.Client.OctopusServerEndpoint $octopusURI,$apikey
$repository = New-Object Octopus.Client.OctopusRepository $endpoint
$project = $repository.Projects.Get($projectId)
$process = $repository.DeploymentProcesses.Get($project.DeploymentProcessId)
$step = $process.Steps | Where-Object Name -Match $stepName
$step.Properties.'Octopus.Action.TargetRoles' = $roleName
Please let me know if this helps or if there is any further advice I can offer.