AsBuiltReport / AsBuiltReport.VMware.vSphere

Repository for AsBuiltReport VMware vSphere module
https://www.asbuiltreport.com
MIT License
112 stars 39 forks source link

Exception calling "Substring" with "1" argument(s) #103

Closed glennbezanson closed 8 months ago

glennbezanson commented 2 years ago

Just started with the AsBuiltReports. I have all prereq's installed but when I attempt to run the vSphere module, I receive an error:

VERBOSE: [ 09:01:00:029 ] [ Document ] - Setting global document options. VERBOSE: [ 09:01:00:029 ] [ Document ] - Enabling section/heading numbering. VERBOSE: [ 09:01:00:030 ] [ Document ] - Setting default font(s) to 'Arial'. VERBOSE: [ 09:01:00:030 ] [ Document ] - Setting page top margin to '25.05'mm. VERBOSE: [ 09:01:00:031 ] [ Document ] - Setting page right margin to '25.05'mm. VERBOSE: [ 09:01:00:031 ] [ Document ] - Setting page bottom margin to '25.05'mm. VERBOSE: [ 09:01:00:031 ] [ Document ] - Setting page left margin to '25.05'mm. VERBOSE: [ 09:01:00:031 ] [ Document ] - Setting page size to 'A4'. VERBOSE: [ 09:01:00:032 ] [ Document ] - Setting page orientation to 'Portrait'. VERBOSE: [ 09:01:00:032 ] [ Document ] - Setting page height to '297'mm. VERBOSE: [ 09:01:00:033 ] [ Document ] - Setting page width to '210'mm. VERBOSE: [ 09:01:00:033 ] [ Document ] - Setting document style 'Title'. VERBOSE: [ 09:01:00:034 ] [ Document ] - Setting document style 'Title2'. VERBOSE: [ 09:01:00:034 ] [ Document ] - Setting document style 'Title3'. VERBOSE: [ 09:01:00:035 ] [ Document ] - Setting document style 'Heading1'. VERBOSE: [ 09:01:00:035 ] [ Document ] - Setting document style 'Heading2'. VERBOSE: [ 09:01:00:036 ] [ Document ] - Setting document style 'Heading3'. VERBOSE: [ 09:01:00:036 ] [ Document ] - Setting document style 'Heading4'. VERBOSE: [ 09:01:00:037 ] [ Document ] - Setting document style 'Heading5'. VERBOSE: [ 09:01:00:037 ] [ Document ] - Setting document style 'Normal'. VERBOSE: [ 09:01:00:038 ] [ Document ] - Setting document style 'Caption'. VERBOSE: [ 09:01:00:038 ] [ Document ] - Setting document style 'Header'. VERBOSE: [ 09:01:00:039 ] [ Document ] - Setting document style 'Footer'. VERBOSE: [ 09:01:00:039 ] [ Document ] - Setting document style 'TOC'. VERBOSE: [ 09:01:00:040 ] [ Document ] - Setting document style 'TableDefaultHeading'. VERBOSE: [ 09:01:00:041 ] [ Document ] - Setting document style 'TableDefaultRow'. VERBOSE: [ 09:01:00:041 ] [ Document ] - Setting document style 'Critical'. VERBOSE: [ 09:01:00:042 ] [ Document ] - Setting document style 'Warning'. VERBOSE: [ 09:01:00:042 ] [ Document ] - Setting document style 'Info'. VERBOSE: [ 09:01:00:043 ] [ Document ] - Setting document style 'OK'. VERBOSE: [ 09:01:00:043 ] [ Document ] - Setting table style 'TableDefault'. VERBOSE: [ 09:01:00:044 ] [ Document ] - Setting table style 'Borderless'. VERBOSE: [ 09:01:00:045 ] [ Document ] - Processing document header started. VERBOSE: [ 09:01:00:046 ] [ Document ] - Processing paragraph 'VMware vSphere As Built Report - v1.0'. VERBOSE: [ 09:01:00:050 ] [ Document ] - Processing document header completed. VERBOSE: [ 09:01:00:050 ] [ Document ] - Processing document footer started. VERBOSE: [ 09:01:00:051 ] [ Document ] - Processing paragraph 'Page <!# PageNumber #!>'. VERBOSE: [ 09:01:00:052 ] [ Document ] - Processing document footer completed. VERBOSE: [ 09:01:00:052 ] [ Document ] - Processing blank line. VERBOSE: [ 09:01:00:053 ] [ Document ] - Processing image 'VMware Logo'. VERBOSE: [ 09:01:00:064 ] [ Document ] - Processing blank line. VERBOSE: [ 09:01:00:065 ] [ Document ] - Processing paragraph 'VMware vSphere As Built Report'. VERBOSE: [ 09:01:00:068 ] [ Document ] - Processing blank line. VERBOSE: [ 09:01:00:069 ] [ Document ] - Processing table 'Cover Page'. VERBOSE: [ 09:01:00:070 ] [ Document ] - Processing page break. VERBOSE: [ 09:01:00:070 ] [ Document ] - Processing table of contents 'Table of Contents'. VERBOSE: [ 09:01:00:070 ] [ Document ] - Processing page break. VERBOSE: [ 09:01:00:097 ] [ Document ] - Connecting to vCenter Server 'vcenter'. VERBOSE: [ 09:01:00:751 ] [ Document ] - Checking vCenter user privileges. VERBOSE: [ 09:01:00:885 ] [ Document ] - Creating VM lookup hashtable. VERBOSE: [ 09:01:02:406 ] [ Document ] - Creating VMHost lookup hashtable. VERBOSE: [ 09:01:02:503 ] [ Document ] - Creating Datastore lookup hashtable. VERBOSE: [ 09:01:02:542 ] [ Document ] - Creating VDPortGroup lookup hashtable. VERBOSE: [ 09:01:02:579 ] [ Document ] - Creating EVC lookup hashtable. VERBOSE: [ 09:01:02:743 ] [ Document ] - Checking for VMware Update Manager Server. VERBOSE: [ 09:01:02:745 ] [ Document ] - Checking for VxRail Manager Server. VERBOSE: [ 09:01:02:745 ] [ Document ] - Checking for VMware Site Recovery Manager Server. VERBOSE: [ 09:01:02:746 ] [ Document ] - Checking for VMware NSX-T Manager Server. VERBOSE: [ 09:01:05:097 ] [ Document ] - Collecting vcenter advanced settings. VERBOSE: [ 09:01:05:197 ] [ Document ] - Processing section 'vcenter' started. VERBOSE: [ 09:01:05:198 ] [ Document ] - vCenter InfoLevel set at 3. VERBOSE: [ 09:01:05:198 ] [ Document ] - Processing section 'vCenter Server' started. VERBOSE: [ 09:01:05:199 ] [ Document ] - Processing paragraph 'The following sections detail the co[..]'. VERBOSE: [ 09:01:05:199 ] [ Document ] - Processing blank line. New-AsBuiltReport: Exception calling "Substring" with "1" argument(s): "startIndex cannot be larger than length of string. (Parameter 'startIndex')"

I am unsure of what is supposed to run at this point, so not sure where to look for an error.

Thank you for any help!

tpcarman commented 2 years ago

Lets try by isolating where the problem might be. It appears to be within the vCenter Server section of the report. Gradually lower the vCenter InfoLevel within the vSphere report JSON configuration file. You're currently using the default setting of 3. Lower it to 2 and re-run the report. Repeat for 1 and then 0 if you continue to have issues, and see if a report generates.

"InfoLevel": {
    "_comment_": "0 = Disabled, 1 = Enabled / Summary, 2 = Adv Summary, 3 = Detailed, 4 = Adv Detailed, 5 = Comprehensive",
    "vCenter": 2,
    "Cluster": 3,
    "ResourcePool": 3,
    "VMHost": 3,
    "Network": 3,
    "vSAN": 3,
    "Datastore": 3,
    "DSCluster": 3,
    "VM": 2,
    "VUM": 3
}
tpcarman commented 2 years ago

Also, can you share what vCenter Server version you are running the report against?

glennbezanson commented 2 years ago

vCenter 7.0.3

I'll try lowering InfoLevel and report back. Thanks for the help!

glennbezanson commented 2 years ago

It worked on InfoLevel 2:

VERBOSE: [ 11:25:49:221 ] [ Document ] - Checking for VMware NSX-T Manager Server. VERBOSE: [ 11:25:49:843 ] [ Document ] - Collecting eic-vc01.gp.eic.dev advanced settings. VERBOSE: [ 11:25:49:905 ] [ Document ] - Processing section 'vcenter' started. VERBOSE: [ 11:25:49:906 ] [ Document ] - vCenter InfoLevel set at 2. VERBOSE: [ 11:25:49:906 ] [ Document ] - Processing section 'vCenter Server' started. VERBOSE: [ 11:25:49:907 ] [ Document ] - Processing paragraph 'The following sections detail the co[..]'. VERBOSE: [ 11:25:49:907 ] [ Document ] - Processing blank line. VERBOSE: [ 11:25:49:916 ] [ Document ] - Processing table 'vCenter Server Summary - vcenter'. VERBOSE: [ 11:25:49:938 ] [ Document ] - Processing section 'vCenter Server' completed. VERBOSE: [ 11:25:49:939 ] [ Document ] - Cluster InfoLevel set at 3. VERBOSE: [ 11:25:50:006 ] [ Document ] - Processing section 'Clusters' started. VERBOSE: [ 11:25:50:030 ] [ Document ] - Processing paragraph 'The following sections detail the co[..]'. VERBOSE: [ 11:25:50:062 ] [ Document ] - Processing section 'infrastructure' started. VERBOSE: [ 11:25:50:087 ] [ Document ] - Processing paragraph 'The following table details the conf[..]'. VERBOSE: [ 11:25:50:088 ] [ Document ] - Processing blank line. VERBOSE: [ 11:25:50:248 ] [ Document ] - Processing table 'Cluster Configuration - infrastructure'.

Report completed as well.

tpcarman commented 2 years ago

Thanks for confirming.

Are you using the vsphere.local domain or a different vsphere domain name?

If you are using a vsphere domain name other than vsphere.local, your issue may be due to a coding error on line 207 of the Invoke-AsBuiltReport.VMware.vSphere.ps1. This will be corrected in a future update, however you might want to update this yourself to see if it resolves your issue.

Current Add-Member @MemberProps -Name 'Platform Services Controller' -Value (($vCenterAdvSettings | Where-Object { $_.name -eq 'config.vpxd.sso.admin.uri' }).Value -replace "^https://|/sso-adminserver/sdk/vsphere.local")

Updated Add-Member @MemberProps -Name 'Platform Services Controller' -Value ((($vCenterAdvSettings).Where{ $_.name -eq 'config.vpxd.sso.admin.uri' }).Value).Split('/')[2]

glennbezanson commented 2 years ago

No, I am using administrator@vsphere.local. I'm running it against a lab we have. I should have included the run line I am using, sorry about that:

New-AsBuiltReport -Report 'VMware.vSphere' -Target 'avcenter' -Username 'administrator@vsphere.local' -Password 'apassword' -Format 'Word','Text' -OutputFolderPath 'C:\Users\GlennBezanson\Scripts\asbuiltreport' -AsBuiltConfigFilePath 'C:\Users\GlennBezanson\AsBuiltReport\AsBuiltReport.json'-EnableHealthCheck -verbose