jamie20
Enthusiast
Enthusiast

Entitlements in csv

Jump to solution

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

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

0 Kudos
10 Replies
LucD
Leadership
Leadership

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

0 Kudos
jamie20
Enthusiast
Enthusiast

Hi LucD,

Thanks for the reply.

Tried the above script and got this output (:

Insert.PNG

0 Kudos
LucD
Leadership
Leadership

So Get-HVPool does not return anything?


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

0 Kudos
jamie20
Enthusiast
Enthusiast

Get-hvpool returns the usual stuff lucd.

Insert.PNG

0 Kudos
LucD
Leadership
Leadership

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

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
0 Kudos
LucD
Leadership
Leadership

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

0 Kudos
jamie20
Enthusiast
Enthusiast

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

"No pool found with given resourcename"

0 Kudos
LucD
Leadership
Leadership

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

0 Kudos
jamie20
Enthusiast
Enthusiast

Bingo....

Its working lucd....Keep rocking.

0 Kudos