VMware Cloud Community
ariolo
Contributor
Contributor

Powercli LicenseKey problem

Hi, 
I am not able to overcome a snag:

I connect to vCenter and I want to loop the esxi hosts to get the LicenseKey for each one; but the format string in output is masking the serial like this: 88888-#####-#####-#####-88888

While, if I execute the same cmdlets but not in a loop, the format is correct and the serial is not masked, like this: 88888-88888-88888-88888-88888



Connect-VIServer -Server myvCenterServer    .... connected

$esxi_hosts= Get-Vmhost 

foreach ($host in $esxi_hosts)


      {

        $host.LicenseKey

      }

 

How can I workaround this?

Many thanks

Luke

Reply
0 Kudos
5 Replies
LucD
Leadership
Leadership

I'm not sure how you can use the $host variable, which is a reserved variable name.
How and from where are you running this?


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

Reply
0 Kudos
ariolo
Contributor
Contributor

Spoiler
Hi

you are right, I use the "$host"  name just to expose here in the board, otherwise it would give error in PowerShell.



Anyway I just found what I did wrong: for my lack of attention the user  that I was in the ViServer session had not permission to see full licenses serial.

I thought I were using the administrator@  user, while I was using a non-admin user.
88888-xxxxx-xxxxx-xxxxx-88888

Thank you

best regards

Luke




So the licenses were correctly showd masked like


Reply
0 Kudos
LucD
Leadership
Leadership

Don't you get an error on the use of the $host variable?


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

Reply
0 Kudos
ariolo
Contributor
Contributor

Spoiler
I did not use really the $host  variable. This would give error as you noticed.


Connect-VIServer -Server myvCenterServer    .... connected

$esxi_hosts= Get-Vmhost 

foreach ($esxi_host in $esxi_hosts)


      {

      $esxi_host.LicenseKey

      }

 

This gave me the  masked output like 88888-#####-#####-#####-88888

I thought I were missing something but I just discovered that I was using for the ViServer session a user with reduced permission. While I thought to be using the administrator@local user.


That is why

I apologize 

The post can be closed or deleted

many thanks



Luke

Reply
0 Kudos
LucD
Leadership
Leadership

No problem.
I prefer to leave the post up, that way someone else with the same issue knows where to look


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