PowerShell CLI VMware View Cmdlet创建具有权利的用户列表

问题描述

我正在尝试从VMware View cmdlet中获取用户和/或组及其权限的列表。到目前为止,我已经有了这个,但是我不确定如何正确使用Get-HVEntitlement cmdlet,我仅发现了基于特定用户名的示例。即使模块正在加载,我似乎也无法完全显示VMware.VimAutomation.Horizo​​nView cmdlet,仅显示VMware.Hv.Helper cmdlet。

Import-Module -Name VMware.PowerCLI
Import-Module -Name VMware.VimAutomation.HorizonView
Import-Module -Name VMware.VimAutomation.Core
Import-Module -Name VMware.Hv.Helper

Set-PowerCLIConfiguration -ProxyPolicy noproxy -Confirm

Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $false
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore
connect-hvserver servername

解决方法

对于模块,请尝试:

Import-Module VMware.VimAutomation.HorizonView
Import-Module VMware.VimAutomation.Core
Import-Module -Name VMware.Hv.Helper

要列出用户和池,您必须结合使用Get-HVPool和Get-HVEntitlement。

类似这样的东西:

$Connection = Connect-HVServer -Server $server -User $user -Password $Password -Domain $domain
                
                $capture = $Connection.ExtensionData
if ($capture)
{

    Get-HVPool | ForEach-Object -Process {
                $currentpool = $_
                
                $entitlements = Get-HVEntitlement -ResourceName $currentpool.Base.Name |
                
                ForEach-Object -Process {
                    
                    $_.Base.LoginName
                    
                }
                
                '' | Select @{ Name = 'Pool'; Expression = { $currentpool.Base.Name } },@{ Name = 'Entitlement'; Expression = { $entitlements -join ',' } }
                
            }} 

PS,看看已经构建的VDIBot(即将推出exe):https://communities.vmware.com/message/2988686#2988686

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...