vmware / PowerCLI-Example-Scripts

http://blogs.vmware.com/powercli
Other
759 stars 604 forks source link

Get-HVEntitlement -ResourceType Desktop #367

Open houk001 opened 4 years ago

houk001 commented 4 years ago

On Example there is option to show Entitlements per Application When i run Get-HVEntitlement -ResourceType Desktop or Get-HVEntitlement -ResourceType Application i get error

Get-HVQueryFilter : Cannot bind argument to parameter 'Filters' because it is an empty array. At C:\Program Files\WindowsPowerShell\Modules\VMware.Hv.Helper\VMware.HV.Helper.psm1:8457 char:54 $AndFilter = Get-HVQueryFilter -And -Filters $AndFilter

 CategoryInfo          : InvalidData: (:) [Get-HVQueryFilter], ParameterBindingValidationException
 FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyArrayNotAllowed,Get-HVQueryFilter

Get-HVQueryResult : Cannot process argument transformation on parameter 'Filter'. Cannot convert the "System.Object[]"
value of type "System.Object[]" to type "VMware.Hv.QueryFilter".
At C:\Program Files\WindowsPowerShell\Modules\VMware.Hv.Helper\VMware.HV.Helper.psm1:8458 char:95
 ... tyType EntitledUserOrGroupLocalSummaryView -Filter $AndFilter -HvServ ...
 CategoryInfo          : InvalidData: (:) [Get-HVQueryResult], ParameterBindingArgumentTransformationException
 FullyQualifiedErrorId : ParameterArgumentTransformationError,Get-HVQueryResult

but when i run not existing resource type there is a info about proper types

Get-HVEntitlement -ResourceType App Get-HVEntitlement : Cannot validate argument on parameter 'ResourceType'. The argument "App" does not belong to th e set "Application;Desktop;GlobalApplicationEntitlement;GlobalEntitlement;URLRedirection" specified by the ValidateSet attribute. Supply an argument that is in the set and then try the command again. At line:1 char:33 Get-HVEntitlement -ResourceType Applicat


     CategoryInfo          : InvalidData: (:) [Get-HVEntitlement], ParameterBindingValidationException
     FullyQualifiedErrorId : ParameterArgumentValidationError,Get-HVEntitlement

Horizon version 7.11 
VMware.Hv.Helper 1.3.1
psurad commented 4 years ago

Hi,

The function expects at least one of “User” or “ResourceName” parameter. The below example script works:

$appEntitlements = Get-HVEntitlement -ResourceType Application -ResourceName 'AppPool' Write-Host 'App entitlements:'; foreach ($info in $appEntitlements) { Write-Host $info.id.id; }

houk001 commented 4 years ago

Then please remove from get-help Get-HVEntitlement -examples a example of usage with only -ResourceType. With old View get-entitlement there is a option to get all of entitlements with pool list, This is very useful to export all of users or group with one command to other systems.