FunMum Posted November 22 Posted November 22 Hi, I am struggling to try to run powercli to get the count of desktops for each Horizon pool. I am receiving the attached error. What am I doing wrong? Import-Module VMware.VimAutomation.Core Import-Module -Name VMware.VimAutomation.HorizonView Import-Module VMware.Hv.Helper Import-Module ImportExcel $server = "myserver" # Specify the output Excel file path $outputExcelFile = "C:\Horizon_Desktop_Counts.xlsx" $adminUser = "" $adminPassword = Read-Host -Prompt "Enter password for $adminUser" -AsSecureString Connect-HVServer -Server $server $pools = Get-HVPool $poolData = @() foreach ($pool in $pools) { $poolName = $pool.Name $desktops = Get-HVMachine -PoolName $poolName -ErrorAction SilentlyContinue if ($desktops) { $desktopCount = $desktops.Count } else { $desktopCount = 0 } $poolData += [PSCustomObject]@{ PoolName = $poolName DesktopCount = $desktopCount } } if ($poolData.Count -gt 0) { $poolData | Export-Excel -Path $outputExcelFile -AutoSize -Title "Desktop Counts Per Pool" Write-Host "Data has been exported to $outputExcelFile." } else { Write-Host "No pool data retrieved. Excel file will not be created." } Disconnect-HVServer -Confirm:$false
Wouter Kursten Posted November 22 Posted November 22 step one is to switch to the Omnissa Powercli as the latest VMware one doesn't have the Horizon modules in it anymore and also the omnissa helper. see https://developer.omnissa.com/horizon-powercli/ (and personally I wouldn't even look at powercli but restapi only as the soap support for the current powercli base is going away. 1
FunMum Posted November 26 Author Posted November 26 @Wouter Kursten, I have followed the instructions and this is what I receive with the module folder in each location. Each of the folders are copied to all the PowerShell module locations
Wouter Kursten Posted November 26 Posted November 26 you need to at least supply a server name to connect to https://retouw.nl/2018/10/08/horizon-view-apis-back-to-basics-part-1-connecting/ 1
FunMum Posted November 26 Author Posted November 26 Disregard, looks like it works..needed powershell7
FunMum Posted November 26 Author Posted November 26 Still getting the same issue if you have any thoughts. I am trying to get a count of each workstation in a pool. # Ensure required modules are loaded # Ensure required modules are loaded Import-module Omnissa.VimAutomation.HorizonView Import-module -name Omnissa.Hv.Helper Import-Module ImportExcel # Specify the Horizon Connection Server $server = "" # Specify the output Excel file path $outputExcelFile = "C:\Horizon_Desktop_Counts.xlsx" # Prompt for admin credentials $adminUser = "y" # Replace with your admin username $adminPassword = Read-Host -Prompt "Enter password for $adminUser" -AsSecureString # Connect to VMware Horizon Connect-HVServer -Server $server # Retrieve pool information $pools = Get-HVPool $poolData = @() foreach ($pool in $pools) { # Adjust field name based on actual structure $poolName = $pool.Name # Use .Name if .Id doesn't work # Retrieve desktops, handling potential failures $desktops = Get-HVMachine -PoolName $poolName -ErrorAction SilentlyContinue if ($desktops) { $desktopCount = $desktops.Count } else { $desktopCount = 0 } # Add data to the array $poolData += [PSCustomObject]@{ PoolName = $poolName DesktopCount = $desktopCount } } # Export data to an Excel file only if there's data if ($poolData.Count -gt 0) { $poolData | Export-Excel -Path $outputExcelFile -AutoSize -Title "Desktop Counts Per Pool" Write-Host "Data has been exported to $outputExcelFile." } else { Write-Host "No pool data retrieved. Excel file will not be created." } # Disconnect from VMware Horizon Disconnect-HVServer -Confirm:$false
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now