Making a call and I have the pool ID correct and post the body in JSON:
You should be only passing an array of machine ids to add to the pool. You appear to be posting user details?
https://developer.vmware.com/apis/1169#/Inventory/addMachines
How about add-machines-by-name:
/inventory/v1/desktop-pools/{id}/action/add-machines-by-name
That's actually what I was trying first. I don't see any other calls that can do the user assignment.
Are you looking to entitle manual pools or automated pools?
it's a manual persistent pool. Users have been connecting to these desktops remotely over vpn/rdp and want to keep the desktop but start using Horizon. They are entitled to the pool by group but I want to add the machine and assign a user to a specific machine because that's where their profiles and apps are.
Got it - let me see if there is a REST API for that. It may only be available with PowerCLI
This endpoint should do it:
/inventory/v1/machines/{id}/action/assign-users
I just tried the add-machines call and that is complaining that the machine is not found in the VC:
It should be this endpoint:
/inventory/v1/machines/{id}/action/assign-users
You need to get the machine ID from: /inventory/v1/machines
That does return list of machines, but only ones that are already registered in pools.
Are you trying to add physical machines with the Horizon Agent to a manual pool and then assign users to it? What type of machine are you trying to add to the manual pool?
VMWare VMs in vcenter the connection servers are connected to
ok make sure the VMs have a Horizon Agent installed.
Where do you see these machines in the Horizon console today?
Are they under Inventory | Machines
or
Settings | Registered Machines
Agent is installed. The machines don't show in Inventory or Registered machines. I can Add from GUI so I am looking for the REST call to replicate that GUI function.
what GUI are you talking about? The Horizon console?
Are you talking about adding vCenter machines into a manual pool this way?
Says I do not have perms to upload images. Desktops -> manual pool -> add
I have the registration working but assigning users is failing
$desktop = Invoke-RestMethod "$($connectionservers)/rest/external/v1/virtual-machines?vcenter_id=$($vcenter_id)" -Method 'GET' -Headers $headers
$desktop = $desktop | where-object {$_.name -eq $computer}
$pools = Invoke-RestMethod "$($connectionservers)/rest/inventory/v1/desktop-pools" -Method 'GET' -Headers $headers
$pool_id = ($pools | Where-Object {$_.name -like $pool}).id
$desktopJ = "[
$($desktop.id | ConvertTo-Json)
]"
$machineRegister = Invoke-RestMethod "$($connectionservers)/rest/inventory/v1/desktop-pools/$($pool_id)/action/add-machines" -Method "POST" -Headers $headers -Body ($desktopJ)
Invoke-RestMethod "$($connectionservers)/rest/inventory/v1/machines/$($machineRegister.id)/action/assign-users" -Method "POST" -Body "[`"XXXXXXXXXXXXXXXXXXXXX`"]"
Invoke-RestMethod:
VMware Horizon
function toggleError()
{
var errorElement = document.getElementById('errorDetails');
if (errorElement && errorElement.style.display == 'none')
{
errorElement.style.display="block";
}
else
{
errorElement.style.display="none";
}
}
function escapeHTML (str)
{
var div = document.createElement('div');
var text = document.createTextNode(str);
div.appendChild(text);
return div.innerHTML;
}
Error: Unsupported Media Type
The page you requested is not available.
var url = escapeHTML(location.href);
if (url.indexOf("http:") == 0 && 415 == "404") {
document.write(" Try HTTPS instead.");
}
Show Details
Error code: 415
Did you get this to work? I am in a similar situation - need to add VMs to manual desktop and couldn't figure out where to get the machineID, as the VMs are not registered yet to any pools.
Hello,
do you find a solution? I've got the same problem. 😞
you need to get the machine id from /external/v1/virtual-machines