Powershell-script for getting a list of machines in a space

Before installing octopus with support for spaces I had a powershell-script to retrieve the url for a specific machine. That doesn’t work anymore. Getting following error:

“You do not have permission to perform this action. Please con
tact your Octopus administrator. Missing permission: MachineView”

I think I need to use constructor something like this:
new OctopusRepository(endpoint, RepositoryScope.ForSpace(space)); (this is c#) and works fine.

Not sure how to do this in Powershell.

Have added the powershell:

Add-Type -Path ‘C:\Program Files\Octopus Deploy\Tentacle\Octopus.Client.dll’

$apikey = ‘API-somesecret’ #admin user
$octopusURI = ‘https://somesecret.url’ # Your server address
$spaceid = “somespacename”

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

$space = $repository.Spaces.FindByName($spaceid)
if (!$space) {
throw “Could not find space”
} else {
Write-Output “Is not null”
}

$repository = New-Object Octopus.Client.OctopusRepository $endpoint , RepositoryScope.ForSpace($space) //something like this…

The last line must be changed to something similar, I guess

Hi Jon!

Thanks for reaching out :slight_smile: You’re absolutely correct that the last line needs to be changed, but only ever so slightly. This should get you unblocked:

$repository = New-Object -TypeName Octopus.Client.OctopusRepository $endpoint, ([Octopus.Client.RepositoryScope]::ForSpace($space))

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.