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