How to use Octopus.Client.Dll to remove variableset and script module from all projects


Can you advise om how to remove a script-module and variable-set from all projects in an Octopus server.
We have a deprecated powershell module, i would like to remove programmatically.

I’ve been trying this, and the Remove() method does return TRUE, howevever. The script-module is still added to my project according to gui.

#Easiest way to get these dlls is to find them
#on the tentacle/Octopus install dir like i’m doing here

Add-Type -Path "C:\Users\kbrandenburg\Documents\Octopus\Newtonsoft.Json.dll"
Add-Type -Path “C:\Users\kbrandenburg\Documents\Octopus\Octopus.Client.dll”

$OctopusURL = “my-server”
$APIKey = “my-key”

$endpoint = new-object Octopus.Client.OctopusServerEndpoint ($OctopusURL, $APIKey)
$c = new-object Octopus.Client.OctopusRepository $endpoint

$projects = $c.Projects.FindByName(“Kb.TestProject1”)

foreach ($project in $projects){

We are running Octopus


Thanks for reaching out. I wrote this Powershell script for you using the Octoposh module. The module uses Octopus.client in the background and it comes with a set of functions that make bulk tasks such as this one much easier. You’re gonna need to have it installed on the Machine that gonna be running this script.

You can get Octoposh from this link:

Here’s the script that will look in all/some projects for a specific VariableSet/Script Module and it will remove it from the project:

Hope that helps!


Thanks. This worked great.