Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vsphere report error New-AsBuiltReport : Cannot bind argument to parameter 'Rows' because it is an empty collection. #69

Closed
EloiseJory opened this issue Sep 17, 2019 · 13 comments
Assignees
Labels
in progress Assignee is currently focusing on this issue

Comments

@EloiseJory
Copy link

Describe the bug
Running as built vsphere report on venter 6.7 u2 and get : Cannot bind argument to parameter 'Rows' because it is an empty collection. just after the processing licensing

To Reproduce
Steps to reproduce the behavior:
New-AsBuiltReport -Report VMware.vSphere -Target 111.222.333.444 -Username vcheck -Password z********** -Format HTML,Word -OutputPath 'd:\Reports'

Expected behavior
Report output into d:\reports.

System (please provide the following information about the system from which you are trying to generate a report):

  • OS: server 2016
  • Windows PowerShell version
    Major Minor Build Revision

5 1 14393 2969

  • 3rd party PowerShell module name and version
    VMware PowerCLI 10.0.0 build 7895300

  • AsBuiltReport Core 1.0.0 AsBuiltReport.Core

  • AsBuiltReport Report module name and version 1.1.0 AsBuiltReport.VMware.vSphere

@mattallford
Copy link
Contributor

mattallford commented Sep 17, 2019

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.

@mattallford mattallford self-assigned this Sep 17, 2019
@EloiseJory
Copy link
Author

EloiseJory commented Sep 17, 2019 via email

@mattallford
Copy link
Contributor

mattallford commented Sep 17, 2019

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

@EloiseJory
Copy link
Author

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 :

@mattallford
Copy link
Contributor

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))

@EloiseJory
Copy link
Author

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:>

@mattallford
Copy link
Contributor

Thoughts @tpcarman?

@EloiseJory
Copy link
Author

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

@EloiseJory
Copy link
Author

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

@tpcarman
Copy link
Contributor

@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?

@EloiseJory
Copy link
Author

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

@tpcarman tpcarman assigned tpcarman and unassigned mattallford Dec 9, 2019
@tpcarman tpcarman added the in progress Assignee is currently focusing on this issue label Dec 9, 2019
@tpcarman
Copy link
Contributor

tpcarman commented Dec 9, 2019

@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.

tpcarman added a commit to tpcarman/AsBuiltReport.VMware.vSphere that referenced this issue Dec 9, 2019
## [1.1.2] - 2019-12-09
### Added
- Added check for minimum VMware PowerCLI version (Fix AsBuiltReport#72)
- Added VM summary information
- Added VM disk and guest volume information
- Added Virtual Switch to VMkernel adapter information
- Added vSAN Disk Groups, iSCSI Targets & LUN reporting

### Changed
- Improved report formatting
- Improved VMHost storage adapter reporting (Fix AsBuiltReport#32)
- Improved VMHost network adapter CDP reporting
- Improved VM SCSI controller reporting
- Updated report JSON structure & default settings. A new report JSON must be generated for this release, use `New-AsBuiltReportConfig -Report VMware.vSphere -Path <path> -Overwrite`.
- Updated README with minimum required privileges to generate a VMware vSphere As Built Report. Full administrator privileges should no longer be required.
- Resolved issue with PCI device reporting when ESXi hosts have FCoE adapters (Fix AsBuiltReport#33)
- Resolved issue with reporting of ESXi boot device size (Fix AsBuiltReport#65)
- Resolved issue with vSphere licensing (Fix # 68 & AsBuiltReport#69)

## Removed
- Removed support for ESX/ESXi hosts prior to vSphere 5.0 (Fix AsBuiltReport#67)
@EloiseJory
Copy link
Author

@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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in progress Assignee is currently focusing on this issue
Projects
None yet
Development

No branches or pull requests

3 participants