We have run into a problem with many of our projects where the “Automatically run configuration transform files” box is checked on a whole bunch of steps in a whole bunch of projects and we’re looking for a programmatic way to update each project/step. I have no problem using the API to locate the steps that need to be updated, however, I cannot find any way to actually change the value ($step.Actions.Properties.‘Octopus.Action.Package.AutomaticallyRunConfigurationTransformationFiles’). It seems like there is an action method or something I am missing and I haven’t been able to locate detailed enough documentation to point me in the right direction. The code I am using is below. Any help is appreciated.
Add-Type -Path “C:\Program Files\WindowsPowerShell\Modules\Octoposh\0.6.11\Octopus.Client.dll”
$apiKeyDev = Import-CliXml -Path ‘C:\DevOctoApiKey.xml’ #Octopus DEV API Key
$apiKey = $apiKeyDev.GetNetworkCredential().Password
$OctopusURL = ‘http:///octo’
$endpoint = New-Object Octopus.Client.OctopusServerEndpoint $octopusURL,$apiKey
$repository = New-Object Octopus.Client.OctopusRepository $endpoint
$projects = $repository.Projects.FindAll()
foreach($project in $projects)
{
$deploymentProcess = $repository.DeploymentProcesses.Get($project.DeploymentProcessId)
foreach ($step in $deploymentProcess.Steps)
{
if(($step.Actions.Properties.'Octopus.Action.Package.AutomaticallyRunConfigurationTransformationFiles').Value -eq $True)
{
#Something needs to happen here, not sure what :)
}
}
$repository.DeploymentProcesses.Modify($deploymentProcess) | Out-Null
}