How to delete a group of users in powershell

I have a powershell script which will return a list of usernames that are no longer using Octopus to a variable, this wass quite simple.
The difficulty I am having is a command to delete the users i have in a variable.
Is there a simple command or syntax that can do this?


$endpoint = New-Object Octopus.Client.OctopusServerEndpoint $OctopusURI,$apikey
$repository = New-Object Octopus.Client.OctopusRepository $endpoint

The delete method doesnt work,



Hi B,

Thanks for reaching out! You need to pass an Octopus.Model.UserResource object to that method and not just their usernames.

I’d recommend you to take a look at the Powershell module Octoposh, which has a lot of cmdlets to interact with Octopus, including one to delete resources such as users:

Hope that helps!