Code Monkey home page Code Monkey logo

Comments (13)

mattallford avatar mattallford commented on June 12, 2024

Hey @EloiseJory,

Thanks for logging the issue. Can you post a screenshot of the console just so we can confirm exactly where it is failing? Please obviously feel free to obfuscate any sensitive information like server names.

What licenses do you have in this environment?

What privileges does the account have that you are running the script as?

Can you try loading the function below, and then after connecting to the vCenter Server with Connect-VIServer, please run the below and report back on what the output is:

Get-License -vCenter vcenter.fqdn.com
Get-License -Licenses

function Get-License {
    <#
.SYNOPSIS
Function to retrieve vSphere product licensing information.
.DESCRIPTION
Function to retrieve vSphere product licensing information.
.NOTES
Version:        0.1.2
Author:         Tim Carman
Twitter:        @tpcarman
Github:         tpcarman
.PARAMETER VMHost
A vSphere ESXi Host object
.PARAMETER vCenter
A vSphere vCenter Server object
.PARAMETER Licenses
All vSphere product licenses
.INPUTS
System.Management.Automation.PSObject.
.OUTPUTS
System.Management.Automation.PSObject.
.EXAMPLE
PS> Get-License -VMHost ESXi01
.EXAMPLE
PS> Get-License -vCenter VCSA
.EXAMPLE
PS> Get-License -Licenses
#>
    [CmdletBinding()][OutputType('System.Management.Automation.PSObject')]

    Param
    (
        [Parameter(Mandatory = $false, ValueFromPipeline = $false)]
        [ValidateNotNullOrEmpty()]
        [PSObject]$vCenter, 
        [PSObject]$VMHost,
        [Parameter(Mandatory = $false, ValueFromPipeline = $false)]
        [Switch]$Licenses
    ) 

    $LicenseObject = @()
    $ServiceInstance = Get-View ServiceInstance -Server $vCenter
    $LicenseManager = Get-View $ServiceInstance.Content.LicenseManager -Server $vCenter
    $LicenseManagerAssign = Get-View $LicenseManager.LicenseAssignmentManager -Server $vCenter
    if ($VMHost) {
        $VMHostId = $VMHost.Extensiondata.Config.Host.Value
        $VMHostAssignedLicense = $LicenseManagerAssign.QueryAssignedLicenses($VMHostId)    
        $VMHostLicense = $VMHostAssignedLicense.AssignedLicense
        if ($VMHostLicense.LicenseKey -and $Options.ShowLicenseKeys) {
            $VMHostLicenseKey = $VMHostLicense.LicenseKey
        } else {
            $VMHostLicenseKey = "*****-*****-*****" + $VMHostLicense.LicenseKey.Substring(17)
        }
        $LicenseObject = [PSCustomObject]@{                               
            Product = $VMHostLicense.Name 
            LicenseKey = $VMHostLicenseKey                   
        }
    }
    if ($vCenter) {
        $vCenterAssignedLicense = $LicenseManagerAssign.GetType().GetMethod("QueryAssignedLicenses").Invoke($LicenseManagerAssign, @($_.MoRef.Value)) | Where-Object { $_.EntityID -eq $vCenter.InstanceUuid }
        $vCenterLicense = $vCenterAssignedLicense.AssignedLicense
        if ($vCenterLicense.LicenseKey -and $Options.ShowLicenseKeys) { 
            $vCenterLicenseKey = $vCenterLicense.LicenseKey
        } else {
            $vCenterLicenseKey = "*****-*****-*****" + $vCenterLicense.LicenseKey.Substring(17)
        }
        $LicenseObject = [PSCustomObject]@{                               
            Product = $vCenterLicense.Name
            LicenseKey = $vCenterLicenseKey                    
        }
    }
    if ($Licenses) {
        foreach ($License in $LicenseManager.Licenses) {
            if ($Options.ShowLicenseKeys) {
                $LicenseKey = $License.LicenseKey
            } else {
                $LicenseKey = "*****-*****-*****" + $License.LicenseKey.Substring(17)
            }
            $Object = [PSCustomObject]@{                               
                'Product' = $License.Name
                'LicenseKey' = $LicenseKey
                'Total' = $License.Total
                'Used' = $License.Used                     
            }
            $LicenseObject += $Object
        }
    }
    Write-Output $LicenseObject
}

Cheers, Matt.

from asbuiltreport.vmware.vsphere.

EloiseJory avatar EloiseJory commented on June 12, 2024

from asbuiltreport.vmware.vsphere.

mattallford avatar mattallford commented on June 12, 2024

Hi @EloiseJory,

Can you try running the following please and sharing the output, while obfuscating the License Keys (please just replace charaters with "x" so we know there was output there.

$vcenter = "vCenterServerName"
Connect-VIServer $vcenter
$ServiceInstance = Get-View ServiceInstance -Server $vCenter
$LicenseManager = Get-View $ServiceInstance.Content.LicenseManager -Server $vCenter
$LicenseManager.Licenses

from asbuiltreport.vmware.vsphere.

EloiseJory avatar EloiseJory commented on June 12, 2024

LicenseKey : 00000-00000-00000-00000-00000
EditionKey : eval
Name : Product Evaluation
Total : 0
Used :
CostUnit :
Properties : {Localized}
Labels :

LicenseKey : xxxxxx
EditionKey : vc.standard.instance
Name : VMware vCenter Server 6 Standard
Total : 1
Used : 1
CostUnit : server
Properties : {LicenseInfo, ProductName, ProductVersion, FileVersion...}
Labels :

LicenseKey : xxxxxx
EditionKey : esx.enterprisePlus.cpuPackage
Name : VMware vSphere 6 Enterprise Plus
Total : 48
Used : 20
CostUnit : cpuPackage
Properties : {LicenseInfo, ProductName, ProductVersion, FileVersion...}
Labels :

LicenseKey : xxxxxxxx
EditionKey : vc.standard.instance
Name : VMware vCenter Server 6 Standard
Total : 1
Used : 1
CostUnit : server
Properties : {LicenseInfo, ProductName, ProductVersion, FileVersion...}
Labels :

from asbuiltreport.vmware.vsphere.

mattallford avatar mattallford commented on June 12, 2024

Hmm. And then these please (following on from the previous commands):

$LicenseManagerAssign = Get-View $LicenseManager.LicenseAssignmentManager -Server $vcenter
$LicenseManagerAssign.GetType().GetMethod("QueryAssignedLicenses").Invoke($LicenseManagerAssign, @($_.MoRef.Value))

from asbuiltreport.vmware.vsphere.

EloiseJory avatar EloiseJory commented on June 12, 2024

there are 2 vcenters in linked mode, however I've previously run the asbuilt report on them one at a time with no problem in 6.5 . This is the first attempt at a 6.7 as built report

PS H:> $LicenseManagerAssign = Get-View $LicenseManager.LicenseAssignmentManager -Server $vcenter
PS H:> $LicenseManagerAssign.GetType().GetMethod("QueryAssignedLicenses").Invoke($LicenseManagerAssign, @($_.MoRef.Valu
e))

EntityId : host-31
Scope : 2f63f088-a629-4d65-a524-fd2e9fd998b4
EntityDisplayName : host3
AssignedLicense : VMware.Vim.LicenseManagerLicenseInfo
Properties : {ProductName, ProductVersion, FileVersion, CostUnit...}

EntityId : host-34
Scope : 2f63f088-a629-4d65-a524-fd2e9fd998b4
EntityDisplayName : host4
AssignedLicense : VMware.Vim.LicenseManagerLicenseInfo
Properties : {ProductName, ProductVersion, FileVersion, CostUnit...}

EntityId : 2f63f088-a629-4d65-a524-fd2e9fd998b4
Scope :
EntityDisplayName : vcenter2
AssignedLicense : VMware.Vim.LicenseManagerLicenseInfo
Properties : {ProductName, ProductVersion, FileVersion, CostUnit...}

EntityId : host-31
Scope : 01ab82aa-4913-43a5-bfd9-a2f7470ac059
EntityDisplayName : host30
AssignedLicense : VMware.Vim.LicenseManagerLicenseInfo
Properties : {ProductName, ProductVersion, FileVersion, CostUnit...}

EntityId : host-531
Scope : 01ab82aa-4913-43a5-bfd9-a2f7470ac059
EntityDisplayName : host35
AssignedLicense : VMware.Vim.LicenseManagerLicenseInfo
Properties : {ProductName, ProductVersion, FileVersion, CostUnit...}

EntityId : host-1072
Scope : 01ab82aa-4913-43a5-bfd9-a2f7470ac059
EntityDisplayName : host36
AssignedLicense : VMware.Vim.LicenseManagerLicenseInfo
Properties : {ProductName, ProductVersion, FileVersion, CostUnit...}

EntityId : host-393
Scope : 01ab82aa-4913-43a5-bfd9-a2f7470ac059
EntityDisplayName : host32
AssignedLicense : VMware.Vim.LicenseManagerLicenseInfo
Properties : {ProductName, ProductVersion, FileVersion, CostUnit...}

EntityId : host-34
Scope : 01ab82aa-4913-43a5-bfd9-a2f7470ac059
EntityDisplayName : host31
AssignedLicense : VMware.Vim.LicenseManagerLicenseInfo
Properties : {ProductName, ProductVersion, FileVersion, CostUnit...}

EntityId : host-1065
Scope : 01ab82aa-4913-43a5-bfd9-a2f7470ac059
EntityDisplayName : host34
AssignedLicense : VMware.Vim.LicenseManagerLicenseInfo
Properties : {ProductName, ProductVersion, FileVersion, CostUnit...}

EntityId : host-1838
Scope : 01ab82aa-4913-43a5-bfd9-a2f7470ac059
EntityDisplayName : host37
AssignedLicense : VMware.Vim.LicenseManagerLicenseInfo
Properties : {ProductName, ProductVersion, FileVersion, CostUnit...}

EntityId : host-388
Scope : 01ab82aa-4913-43a5-bfd9-a2f7470ac059
EntityDisplayName : host33
AssignedLicense : VMware.Vim.LicenseManagerLicenseInfo
Properties : {ProductName, ProductVersion, FileVersion, CostUnit...}

EntityId : 01ab82aa-4913-43a5-bfd9-a2f7470ac059
Scope :
EntityDisplayName : vcenter2
AssignedLicense : VMware.Vim.LicenseManagerLicenseInfo
Properties : {ProductName, ProductVersion, FileVersion, CostUnit...}

PS H:>

from asbuiltreport.vmware.vsphere.

mattallford avatar mattallford commented on June 12, 2024

Thoughts @tpcarman?

from asbuiltreport.vmware.vsphere.

EloiseJory avatar EloiseJory commented on June 12, 2024

can I stop the licence part from running? comment out something?

from asbuiltreport.vmware.vsphere.

EloiseJory avatar EloiseJory commented on June 12, 2024

Is there a section I can comment out so the report will run without licencing info?

from asbuiltreport.vmware.vsphere.

tpcarman avatar tpcarman commented on June 12, 2024

@EloiseJory It's probably worth having a look at your environment and seeing what is happening first hand. Would that be possible? Can we arrange a screen sharing session at some stage?

from asbuiltreport.vmware.vsphere.

EloiseJory avatar EloiseJory commented on June 12, 2024

@tpcarman ill have to check with management and get back to you....

from asbuiltreport.vmware.vsphere.

tpcarman avatar tpcarman commented on June 12, 2024

@EloiseJory I believe I have identified the issue and looking to include the fix in the next update, due soon. Let me know if you wish to test before release.

from asbuiltreport.vmware.vsphere.

EloiseJory avatar EloiseJory commented on June 12, 2024

@EloiseJory I believe I have identified the issue and looking to include the fix in the next update, due soon. Let me know if you wish to test before release.

I can give it a test...

from asbuiltreport.vmware.vsphere.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.