Using Octoposh 0.6.11
Want to add a variable to a list of projects:
$variableset = Get-OctopusVariableSet -Projectname $projectName -ResourceOnly
$newvariable = New-Object Octopus.Client.Model.VariableResource
$scope = New-Object Octopus.Platform.Model.ScopeSpecification
New-Object : Cannot find type [Octopus.Platform.Model.ScopeSpecification]: verify that the assembly containing this type is loaded.
It looks like I need specific Octopus Dlls for the Octoposh scripts to run.
Any ideas please?
Hi @terry.ninnis ,
Thanks for getting in touch!
The Octoposh module isn’t actively maintained anymore, so this issue could be due to compatibility issues with newer versions of Octopus.
We do have a repository of useful scripts for the octopus.client available here .
This one, in particular, will allow you to add or update a variable within a single project. You should be able to amend it to loop through a list of projects.
cls
function UpdateVarInProject {
Param (
[Parameter(Mandatory=$true)][string] $UserApiKey,
[Parameter(Mandatory=$true)][string] $OctopusUrl,
[Parameter(Mandatory=$true)][string] $ProjectName,
[Parameter(Mandatory=$true)][string] $VariableToModify,
[Parameter(Mandatory=$true)][string] $VariableValue,
[Parameter()][string] $EnvironmentScope,
[Parameter()][string] $RoleScope,
[Parameter()][string] $MachineScope,
[Parameter()][string] $ActionScope
)
Process {
Set-Location "C:\Program Files\Octopus Deploy\Tentacle"
Add-Type -Path 'Newtonsoft.Json.dll'
Add-Type -Path 'Octopus.Client.dll'
$endpoint = New-Object Octopus.Client.OctopusServerEndpoint $OctopusUrl,$UserApiKey
$repository = New-Object Octopus.Client.OctopusRepository $endpoint
$project = $repository.Projects.FindByName($ProjectName)
This file has been truncated. show original
Regards,
Paul
Thanks Paul,
That works perfectly.
1 Like
system
(system)
Closed
13 August 2020 11:13
5
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.