VMware Cloud Community
jamie20
Enthusiast
Enthusiast
Jump to solution

Entitlements in csv

Hi guys,

I am trying to make a script which gets entitlements of all the desktop pools.

I could take entitlements of a single desktop pool by below script.

$desEntitlements = Get-HVEntitlement -ResourceName 'desktop-pool-01'

Write-Host 'Desktop entitlements:';

foreach ($info in $desEntitlements) {

write-host $info.base.loginname;

}

Output:

Desktop entitlements:

user01

user02

But dont know how to fetch it for all the desktop pools of the connected view server.

Expected csv output:

Desktop Pool NameEntitlement
desktop-pool-01user01, user02
desktop-pool-02user01, user03

.

.

.

Any help?

1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Strange.

And when you do it this way?

Get-HVPool | ForEach-Object -Process {

    $pool = $_

    $entitlements = Get-HVEntitlement -ResourceName $pool.Base.Name |

    ForEach-Object -Process {

        $_.Base.LoginName

    }

    '' |Select @{N='Desktop Pool Name';E={$pool.Base.Name}},

        @{N='Entitlement';E={$entitlements -join ','}}

}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
10 Replies
LucD
Leadership
Leadership
Jump to solution

Something like this?

Get-HVPool | ForEach-Object -Process {

    $pool = $_

    Get-HVEntitlement -ResourceName $pool |

    Select @{N='Desktop Pool Name';E={$pool.Base.Name}},

        @{N='Entitlement';E={$_.Base.LoginName -join '|'}}

}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
jamie20
Enthusiast
Enthusiast
Jump to solution

Hi LucD,

Thanks for the reply.

Tried the above script and got this output (:

Insert.PNG

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

So Get-HVPool does not return anything?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
jamie20
Enthusiast
Enthusiast
Jump to solution

Get-hvpool returns the usual stuff lucd.

Insert.PNG

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

And if you replace that line with

    Get-HVEntitlement -ResourceName $pool.Base.Name |


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

jamie20
Enthusiast
Enthusiast
Jump to solution

Awesome Lucd....Its working now.

Now the output is like,each entitlement takes a separate row for the same desktop pool.

Example:

 

Desktop Pool NameEntitlement
desktop-pool-01user01
desktop-pool-01user02
desktop-pool-01user03
desktop-pool-02user02

How to make the entitlements of single desktop pool in a single row. Like,

Desktop Pool NameEntitlement
desktop-pool-01user01, user02, user03
desktop-pool-02user02,user04
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Try something like this then

Get-HVPool |

Select N='Desktop Pool Name';E={$_.Base.Name}},

    @{N='Entitlement';E={(Get-HVEntitlement -ResourceName $_.Base.Name).Base.LoginName -join ','}}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
jamie20
Enthusiast
Enthusiast
Jump to solution

No Lucd...It is returning the error again.

"No pool found with given resourcename"

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Strange.

And when you do it this way?

Get-HVPool | ForEach-Object -Process {

    $pool = $_

    $entitlements = Get-HVEntitlement -ResourceName $pool.Base.Name |

    ForEach-Object -Process {

        $_.Base.LoginName

    }

    '' |Select @{N='Desktop Pool Name';E={$pool.Base.Name}},

        @{N='Entitlement';E={$entitlements -join ','}}

}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
jamie20
Enthusiast
Enthusiast
Jump to solution

Bingo....

Its working lucd....Keep rocking.

Reply
0 Kudos