AsBuiltReport.VMware.vSphere
AsBuiltReport.VMware.vSphere copied to clipboard
New-AsBuiltReport: Index operation failed; the array index evaluated to null.
Bug description
Everytime I run a new report this error gets thrown. New-AsBuiltReport: Index operation failed; the array index evaluated to null. Also, in a -verbose it states: VERBOSE: [ 11:10:43:637 ] [ Document ] - Insufficient user privileges to report ESXi host licensing. Please ensure the user account has the 'Global > Licenses' privilege assigned.
but iit is run with [email protected]
Command-line input
New-AsBuiltReport -Report VMware.vSphere -Target 'vcenter.ad.local' -Username '[email protected]' -Password 'password' -Format Word -OutputPath "C:\Reports" -ReportConfigPath "C:\Reports\1Script\Config\fullBuiltReport.VMware.vSphere.json" -TimeStamp -EnableHealthcheck -verbose
Steps to reproduce
"InfoLevel": { "comment": "0 = Disabled, 1 = Enabled / Summary, 2 = Adv Summary, 3 = Detailed, 4 = Adv Detailed, 5 = Comprehensive", "vCenter": 4, "Cluster": 4, "ResourcePool": 4, "VMHost": 2, << if this is set higher than 2, it failes "Network": 4, "vSAN": 0, "Datastore": 4, "DSCluster": 4, "VM": 4, "VUM": 4
Expected behaviour
for it to work.
Screenshots
No response
Operating System
Windows 11
PowerShell Version
Name Value
PSVersion 7.4.5 PSEdition Core GitCommitId 7.4.5 OS Microsoft Windows 10.0.22631 Platform Win32NT PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…} PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 WSManStackVersion 3.0
PowerShell Modules
Name Version
AsBuiltReport.Core 1.4.0 AsBuiltReport.VMware.vSphere 1.3.4.1 PScribo 0.10.0
Additional Context
No response
Before submitting
- [X] I have read and followed the bug reporting guidelines.
- [X] I have read the documentation, and referred to the known issues before submitting this bug report.
- [X] I have checked for previously opened & closed issues before submitting this bug report.
What vSphere version are you running? Can you share any more information about the number and types of licenses you currently have?
AsBuiltReport.Core = v1.4.0 AsBuiltReport.VMware.vSphere = v.1.3.4.1 Powershell = 7.4.5 ESXi = 8.0.2 build-23305546 (U2b) vCenter = 8.0.2 built-23504390 (U2c)
vSphere 8 Enterprise Plus (Perpetual) vCenter Server 8 Standard (Perpetual)
I run the script with the unedited [email protected] user. (Full rights)
Does the vCenter license section or any other license keys show within the generated report?
Can you try and run the following script to see if Global.Licenses is listed in the output. If it is not then your account doesn't appear to have the privileges to collect license information.
$server = <your vcenter IP/FQDN>
$vccreds = get-credential -username [email protected]
$vcenter = connect-viserver $server -credential $vccreds
Try {
$UserPermission = Get-VIPermission | Where-Object { $_.Principal -eq $vCenter.User }
$AuthMgr = Get-View $($vCenter.ExtensionData.Content.AuthorizationManager)
$UserRole = $AuthMgr.RoleList | Where-Object { $_.Name -eq $($UserPermission.Role) }
$UserRole.Privilege -like 'Global.*'
} Catch {
Write-Error $_
}
You should see an output similar to this
Global.CancelTask
Global.CapacityPlanning
Global.Diagnostics
Global.DisableMethods
Global.EnableMethods
Global.GlobalTag
Global.Health
Global.Licenses
Global.LogEvent
Global.ManageCustomFields
Global.Proxy
Global.ScriptAction
Global.ServiceManagers
Global.SetCustomField
Global.Settings
Global.SystemTag
Global.VCServer
You may also want to try to update the Get-License.ps1 file as outlined in issue #128
@Big-Giant-Head Can you test with https://github.com/AsBuiltReport/AsBuiltReport.VMware.vSphere/commit/c68516433c2b3f00dc3991ce28166beb6d3cfc2f and let me know if it resolves your issue?
Hello @tpcarman , I came to the same issue while using the AsBuiltReport, I tested your script from 17.2 and it does not work with the latest vcenter 8 release. here an output `PS C:\Users\stanke> $vcenter = connect-viserver $server -credential $vccreds PS C:\Users\stanke> PS C:\Users\stanke> Try {
$UserPermission = Get-VIPermission | Where-Object { $_.Principal -eq $vCenter.User } $AuthMgr = Get-View $($vCenter.ExtensionData.Content.AuthorizationManager) $UserRole = $AuthMgr.RoleList | Where-Object { $_.Name -eq $($UserPermission.Role) } $UserRole.Privilege -like 'Global.*'} Catch { Write-Error $_ } False PS C:\Users\stanke>`
while running it on vcenter version 7 replies with following `PS C:\Users\stanke> $vcenter = connect-viserver $server -credential $vccreds PS C:\Users\stanke> Try {
$UserPermission = Get-VIPermission | Where-Object { $_.Principal -eq $vCenter.User } $AuthMgr = Get-View $($vCenter.ExtensionData.Content.AuthorizationManager) $UserRole = $AuthMgr.RoleList | Where-Object { $_.Name -eq $($UserPermission.Role) } $UserRole.Privilege -like 'Global.*'} Catch { Write-Error $_ } Global.CancelTask Global.CapacityPlanning Global.Diagnostics Global.DisableMethods Global.EnableMethods Global.GlobalTag Global.Health Global.Licenses Global.LogEvent Global.ManageCustomFields Global.Proxy Global.ScriptAction Global.ServiceManagers Global.SetCustomField Global.Settings Global.SystemTag Global.VCServer`
I have both VMware versions available for any testing and willing to help to fix the problem.
Thank you
it does not work with the latest vcenter 8 release
What version are you using?
Due to Broadcom's changes with updates, it is now much more difficult for me to test new releases.
I am currently working with vCenter Server 8.0.3.00400
I've managed to test this against vCenter Server 8.0.3.00500 and am not seeing an issue.
Are you running the code which is currently in the dev branch?