Hello,
i tryed to catch License Infos over powershell.
on point i don't know how to query ;(
how is it possible to query which License key is binded to which ESX.
right now i have this code. ( i copied only the contenct from my whole script.)
May somebody could help me outta the space?
many thx
markus
Yes, I could reproduce the error. Seems to come from unassigned evaluation licenses.
Try this slightly adapted script.
$showVCLicense = $true ###################### # VMware VC License # ###################### if ($ShowVCLicense){ # Write-CustomOut "..Adding Licence Infos to the report" $LicenseMan = Get-View LicenseManager $licAssignMgr = Get-View LicenseAssignmentManager $licArr = @() foreach($esx in (Get-View -ViewType HostSystem)){ $assignment = $licAssignMgr.QueryAssignedLicenses($esx.MoRef.Value) $assignment | %{ $row = "" | Select HostName, LicName, LicKey $row.HostName = $esx.Name $row.LicName = $_.AssignedLicense.Name $row.LicKey = $_.AssignedLicense.LicenseKey $licArr += $row } } $vSphereLicInfo = @() foreach ($License in $LicenseMan.Licenses){ $Details = "" |Select Name, Key, Total, Used,Information, UsedBy $Details.Name= $License.Name $Details.Key= $License.LicenseKey $Details.Total= $License.Total $Details.Used= $License.Used $Details.Information= $License.Labels |Select -expand Value $hostsAssigned = $licArr | where {$_.LicKey -eq $License.LicenseKey} | %{$_.HostName} if(!$hostsAssigned){$hostsAssigned = ""} $Details.UsedBy = [string]::Join(",",$hostsAssigned) $vSphereLicInfo += $Details } $vSphereLicInfo }
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Sure, try this (note that it requires vSphere 4.x)
$licAssignMgr = Get-View LicenseAssignmentManager $report = @() foreach($esx in (Get-View -ViewType HostSystem)){ $assignment = $licAssignMgr.QueryAssignedLicenses($esx.MoRef.Value) $assignment | %{ $row = "" | Select HostName, LicName, LicKey $row.HostName = $esx.Name $row.LicName = $_.AssignedLicense.Name $row.LicKey = $_.AssignedLicense.LicenseKey $report += $row } } $report
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hello Luc,
many thx for your answer.
one question for that.
how could i merge this into my code. so that i also have the (Virtual center license, total,used,...)
many thx
Markus
Sure, perhaps something like this
$showVCLicense = $true ###################### # VMware VC License # ###################### if ($ShowVCLicense){ # Write-CustomOut "..Adding Licence Infos to the report" $LicenseMan = Get-View LicenseManager $licAssignMgr = Get-View LicenseAssignmentManager $licArr = @() foreach($esx in (Get-View -ViewType HostSystem)){ $assignment = $licAssignMgr.QueryAssignedLicenses($esx.MoRef.Value) $assignment | %{ $row = "" | Select HostName, LicName, LicKey $row.HostName = $esx.Name $row.LicName = $_.AssignedLicense.Name $row.LicKey = $_.AssignedLicense.LicenseKey $licArr += $row } } $vSphereLicInfo = @() foreach ($License in $LicenseMan.Licenses){ $Details = “” |Select Name, Key, Total, Used,Information, UsedBy $Details.Name= $License.Name $Details.Key= $License.LicenseKey $Details.Total= $License.Total $Details.Used= $License.Used $Details.Information= $License.Labels |Select -expand Value $Details.UsedBy = [string]::Join(",",($licArr | where {$_.LicKey -eq $License.LicenseKey} | %{$_.HostName})) $vSphereLicInfo += $Details } $vSphereLicInfo }
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi theire,
i got a little error at the beginn
Select-Object : Cannot expand property "Value" because it has nothing to expand
Exception calling "Join" with "2" argument(s): "Value cannot be null.
Have many thx
Markus
Yes, I could reproduce the error. Seems to come from unassigned evaluation licenses.
Try this slightly adapted script.
$showVCLicense = $true ###################### # VMware VC License # ###################### if ($ShowVCLicense){ # Write-CustomOut "..Adding Licence Infos to the report" $LicenseMan = Get-View LicenseManager $licAssignMgr = Get-View LicenseAssignmentManager $licArr = @() foreach($esx in (Get-View -ViewType HostSystem)){ $assignment = $licAssignMgr.QueryAssignedLicenses($esx.MoRef.Value) $assignment | %{ $row = "" | Select HostName, LicName, LicKey $row.HostName = $esx.Name $row.LicName = $_.AssignedLicense.Name $row.LicKey = $_.AssignedLicense.LicenseKey $licArr += $row } } $vSphereLicInfo = @() foreach ($License in $LicenseMan.Licenses){ $Details = "" |Select Name, Key, Total, Used,Information, UsedBy $Details.Name= $License.Name $Details.Key= $License.LicenseKey $Details.Total= $License.Total $Details.Used= $License.Used $Details.Information= $License.Labels |Select -expand Value $hostsAssigned = $licArr | where {$_.LicKey -eq $License.LicenseKey} | %{$_.HostName} if(!$hostsAssigned){$hostsAssigned = ""} $Details.UsedBy = [string]::Join(",",$hostsAssigned) $vSphereLicInfo += $Details } $vSphereLicInfo }
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference