VMware Horizon Community
angelcat00
Contributor
Contributor

horizon powercli manual pool in machin user permission script

$Pool = "dedicated"
$new_pool = "test2"
$vms = Get-HVMachineSummary -PoolName $Pool
$results = @()
foreach($vm in $vms){
$machine = $null
$machine = Get-VM -Name $vm.Base.Name
$properties = @{
UserName = $vm.NamesData.UserName
MachineName = $vm.Base.Name
}
$results += New-Object psobject -Property $properties
}

$results | export-csv -NoTypeInformation -path c:\test1.csv

sleep 5

$list = import-csv "C:\test1.csv"

foreach($col in $list)
{

$um = $col.UserName
$mc = $col.MachineName

Remove-HVMachine -MachineName $mc -DeleteFromDisk:$false -confirm:$false

Add-HVDesktop -PoolName $new_pool -Machines $mc -confirm:$false

 

 

Testing has been completed until moving from the old pool to the new pool by executing the above script. However, after referring to Excel for user assignment of virtual machines assigned to the existing pool, we want to automatically assign them to the new pool. Could you please help on this part?

 

Labels (1)
Tags (1)
Reply
0 Kudos
1 Reply
RoderikdeBlock
Enthusiast
Enthusiast

Take a look at this thread: Assign user in Dedicated pool with Powershell - VMware Technology Network VMTN

Set-HVMachine -HvServer $vcs -MachineName machine.fqdn -User "domain\user"

 

Get-HVMachine -MachineName machine.fqdn | Set-HVMachine -User user@domain

 

Roderik de Block


Blog: https://roderikdeblock.com
Reply
0 Kudos