Kanji5575
Contributor
Contributor

Script to export License usage report from Vcenter

Jump to solution

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

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 .

0 Kudos
LucD
Leadership
Leadership

Works for me


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

0 Kudos
Naga2
Contributor
Contributor

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

 

0 Kudos
LucD
Leadership
Leadership

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


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

0 Kudos
Naga2
Contributor
Contributor

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

0 Kudos
LucD
Leadership
Leadership

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

0 Kudos
Naga2
Contributor
Contributor

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

 

 

0 Kudos
LucD
Leadership
Leadership

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


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

0 Kudos
Naga2
Contributor
Contributor

Here you go .

 

Naga2_0-1655921725610.png

 

0 Kudos
LucD
Leadership
Leadership

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

0 Kudos