VMware Cloud Community
Kanji5575
Contributor
Contributor
Jump to solution

Script to export License usage report from Vcenter

Can someone help me with script to Export License usage report from Vcenter. This is done manually by logging into webclient> Licensing> reports> products > Export License Usage Report > .

29 Replies
system_noida
Enthusiast
Enthusiast
Jump to solution

Hi @LucD , How can I export these licenses details please . I tried to put | export-csv $outputpath but its not collecting the details.

please can you help me .

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Works for me


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

Reply
0 Kudos
Naga2
Contributor
Contributor
Jump to solution

HI LucD,

 I receive the following error on line 3   ($LicenseAssignmentManager.GetType().GetMethod("QueryAssignedLicenses").Invoke($LicenseAssignmentManager,@($null)) |), when I try executing the script  .  It says I cant use "null"

 

 

Naga2_0-1655915253754.png

 

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Did the first 2 lines produce any errors?
Is there anything in $LicenseAssignmentManager?


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

Reply
0 Kudos
Naga2
Contributor
Contributor
Jump to solution

Nope,, It doesn't , however, in the 3rd line also ,  it gave me an error for  $LicenseAssignmentManager  and I cant use "null" expressions or variables

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Can you be more specific, perhaps add a screenshot?
Did you check the content of $LicenseAssignmentManager?


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

Reply
0 Kudos
Naga2
Contributor
Contributor
Jump to solution

Please find the screenshot for you reference.  Am new to the powercli scripting, I dont know if am doing something wrong

 

Naga2_1-1655919335128.png

 

 

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Can you just type $LicenseAssignmentManager at the command prompt, and check what it returns?


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

Reply
0 Kudos
Naga2
Contributor
Contributor
Jump to solution

Here you go .

 

Naga2_0-1655921725610.png

 

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Ok, I know what happened.
You have multiple vCenter connections open.
You can check with displaying $global:defaultVIServers.

Close all those connections with

Disconnect-VIServer -Server * -Force -Confirm:$false


Then run that code again.
But perhaps add a Disconnect-VIServer at the end of the script to avoid the same issue on a 2nd or subsequent run of the script


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

Reply
0 Kudos