I have the script below (thanks to Alan for his help with this) that lists all the license info for my hosts.
$ESXHosts = Get-VMHost \ | get-view $ServiceInstance = Get-View ServiceInstance $LicenseMan = Get-View $ServiceInstance.Content.LicenseManager $Query = $LicenseMan.QueryLicenseUsage foreach ($ESXHost in $ESXHosts) { $LicUse = $LicenseMan.QueryLicenseUsage($ESXHost.MoRef) $esxlic = $licuse.reservationinfo \ | select @{N="Feature";E={$_.key}}, @{N="No. Licenses"; E={$_.required}}, @{N="Licensed State";E={$_.state}} $heading = "<h4>" \ | out-file -append $filelocation $esxhost.name \ | out-file -append $filelocation $altheading = "</h4>" \ | out-file -append $filelocation $esxlic \ | ConvertTo-Html -body "" \ | Out-File -Append $filelocation } |
The only problem is when exported to a html file, it produces a long list, which although correct is not nice to view with loads of hosts.
The table for each host looks like the table below.
hostname.domain
Feature | No. Licenses | Licensed State |
esxHost | 8 | licensed |
vmotion | 8 | licensed |
drs | 8 | licensed |
das | 8 | licensed |
esxFull | 8 | licensed |
vsmp | 8 | licensed |
nas | 8 | licensed |
iscsi | 8 | licensed |
san | 8 | licensed |
What I want is for the table to look like the table below.
hostname | esxhost | vmotion | drs | das | esxFull | vmsp | nas | iscsi | san | licensed state |
host 1 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | Licensed |
So that it is easy to quickly see the licensed features of all the hosts, and perhaps the licensed state only saying licensed it licenses are in use for all the different components, otherwise saying partial license for example.
In fact I would be happy to leave out the licensed state if I could list everything as in the table above as then I can quickly see what is licensed.
Thanks in advance for any assistance.
Rog.
Ok, I think what you want is something like the below code. I have left out the licensed feild as this is a per feature detail which can not be represented properly in some cases...
$ESXHosts = Get-VMHost | get-view $ServiceInstance = Get-View ServiceInstance $LicenseMan = Get-View $ServiceInstance.Content.LicenseManager $Report = @() foreach ($ESXHost in $ESXHosts) { $Lic = "" | Select Host, esxHost, VMotion, DRS, HA, ESXFull,esxExpress, Backup, VSMP, NAS, iSCSI, SAN $LicUse = $LicenseMan.QueryLicenseUsage($ESXHost.MoRef) $esxlic = $licuse.reservationinfo | select @{N="Feature";E={$_.key}}, @{N="No. Licenses"; E={$_.required}}, @{N="Licensed State";E={$_.state}} $Lic.Host = $ESXHost.Name $Lic.esxHost = ($esxlic | where {$_.Feature -eq "esxHost"})."No. Licenses" $Lic.VMotion = ($esxlic | where {$_.Feature -eq "VMotion"})."No. Licenses" $Lic.DRS = ($esxlic | where {$_.Feature -eq "DRS"})."No. Licenses" $Lic.HA = ($esxlic | where {$_.Feature -eq "DAS"})."No. Licenses" $Lic.ESXFull = ($esxlic | where {$_.Feature -eq "ESXFull"})."No. Licenses" $Lic.esxExpress = ($esxlic | where {$_.Feature -eq "esxExpress"})."No. Licenses" $Lic.Backup = ($esxlic | where {$_.Feature -eq "Backup"})."No. Licenses" $Lic.VSMP = ($esxlic | where {$_.Feature -eq "VSMP"})."No. Licenses" $Lic.NAS = ($esxlic | where {$_.Feature -eq "NAS"})."No. Licenses" $Lic.iSCSI = ($esxlic | where {$_.Feature -eq "iSCSI"})."No. Licenses" $Lic.SAN = ($esxlic | where {$_.Feature -eq "SAN"})."No. Licenses" $Report += $Lic } $Report | ConvertTo-Html -body "" |Out-File -Append $filelocation
If you found this information useful, please consider awarding points for Correct or Helpful.
Alan Renouf
You would have to re-work the script to add them up and present them like this, want me to give it a go ?
If you found this information useful, please consider awarding points for Correct or Helpful.
Alan Renouf
Hi Alan,
Yes I would love you to give this a go.
I've been trying for a while with no success!
I really need to get Hal's Powershell book, perhaps I will try and do this at the weekend.
Ok, I think what you want is something like the below code. I have left out the licensed feild as this is a per feature detail which can not be represented properly in some cases...
$ESXHosts = Get-VMHost | get-view $ServiceInstance = Get-View ServiceInstance $LicenseMan = Get-View $ServiceInstance.Content.LicenseManager $Report = @() foreach ($ESXHost in $ESXHosts) { $Lic = "" | Select Host, esxHost, VMotion, DRS, HA, ESXFull,esxExpress, Backup, VSMP, NAS, iSCSI, SAN $LicUse = $LicenseMan.QueryLicenseUsage($ESXHost.MoRef) $esxlic = $licuse.reservationinfo | select @{N="Feature";E={$_.key}}, @{N="No. Licenses"; E={$_.required}}, @{N="Licensed State";E={$_.state}} $Lic.Host = $ESXHost.Name $Lic.esxHost = ($esxlic | where {$_.Feature -eq "esxHost"})."No. Licenses" $Lic.VMotion = ($esxlic | where {$_.Feature -eq "VMotion"})."No. Licenses" $Lic.DRS = ($esxlic | where {$_.Feature -eq "DRS"})."No. Licenses" $Lic.HA = ($esxlic | where {$_.Feature -eq "DAS"})."No. Licenses" $Lic.ESXFull = ($esxlic | where {$_.Feature -eq "ESXFull"})."No. Licenses" $Lic.esxExpress = ($esxlic | where {$_.Feature -eq "esxExpress"})."No. Licenses" $Lic.Backup = ($esxlic | where {$_.Feature -eq "Backup"})."No. Licenses" $Lic.VSMP = ($esxlic | where {$_.Feature -eq "VSMP"})."No. Licenses" $Lic.NAS = ($esxlic | where {$_.Feature -eq "NAS"})."No. Licenses" $Lic.iSCSI = ($esxlic | where {$_.Feature -eq "iSCSI"})."No. Licenses" $Lic.SAN = ($esxlic | where {$_.Feature -eq "SAN"})."No. Licenses" $Report += $Lic } $Report | ConvertTo-Html -body "" |Out-File -Append $filelocation
If you found this information useful, please consider awarding points for Correct or Helpful.
Alan Renouf
Actually, just re-read your original post about the license/partial license field, let me know if you want this in there too but i think the results are clear anyway.
If you found this information useful, please consider awarding points for Correct or Helpful.
Alan Renouf
Hi Alan,
That is great, displays everything I need. Thanks for your help.
From my point of view, I was on the right lines trying to create it in this format, was just my syntax that was off (by quite a lot!!!)
Again thanks, I'm learning from all this!
Regards,
Roger.
No probs, im sure there is an easier way but for the life of me cant thinks what it is right now !
If you found this information useful, please consider awarding points for Correct or Helpful.
Alan Renouf