Closed mattallford closed 4 years ago
If I run New-AsBuiltReport and export to text, as noted above it runs OK. In the Assigned Tag output, I can see there is a tag but the entity is empty for some reason:
However if I simply run Get-TagAssignment -Server vcenter.domain.com at the command line, I get the entity in the results:
If I browse to that VM entity in the web client, under Tags I can see the tag is assigned.
Also if I browse to the Tags & custom attributes section and select the tag, I can see that is is assigned to one object from the vCenter Server I am running As Built against. Interestingly enough the same tag is assigned to objects from another (linked) vCenter Server as well. Not sure if that's an issue, it shouldn't be by the use of the -Server parameter on Get-TagAssignment, just an observation at the moment.
Man, this is getting weird.
I just used VC Code to put a breakpoint on the cmdlet Get-TagAssignment and then ran New-AsbuiltReport.
It broke on this line, which is what I expected:
$TagAssignments = Get-TagAssignment -Server $vCenter
So I then ran just that line, and checked the output of $TagAssignments. All good and the entity is shown here against the tag that I thought was going to be empty as per above:
So then I let the rest of the script run, and it completed without issue and generated the HTML report!
If I remove the breakpoint and run exactly the same thing again from the current session, the report works:
VERBOSE: [ 13:51:19:220 ] [ Document ] - Processing section 'VMware Update Manager' completed.
VERBOSE: [ 13:51:19:223 ] [ Document ] - Processing section 'vcenter01.domain.com' completed.
VERBOSE: [ 13:51:19:240 ] [ Document ] - Document 'VMware vSphere As Built Report - 2020-03-12_13.50.33' processing completed.
VERBOSE: [ 13:51:19:242 ] [ Document ] - Total processing time '46.22' seconds.
VMware vSphere As Built Report - 2020-03-12_13.50.33 has been saved to E:\vSphere 6.7 U3 Upgrade\Asbuilt
I actually ran it 4 times to make sure and it worked every time.
I then killed the Powershell terminal in VS Code and started a new one and ran exactly the same code again, and now we are back to it failing as per the original post.
Describe the bug When running the vSphere As Built Report against some environments (not all), the script seems to run OK, but right at the end where the document should be generated, the script exits with the following error:
I have narrowed this down and it only occurs if the vCenter Server level is set to 3 or higher, and the specific section of code that is causing the problem is related to vSphere Tag Assignments:
If the above section of code is removed or commented, the script will run with no issues at all.
In the environment I am running this against currently, there are two vCenter Servers running the same build (detailed below), but the script runs fine against one vCenter Server yet not the other.
In the problematic vSphere environment there are 138 tag assignments, in the environment that works OK there are 682 tag assignments.
To Reproduce It doesn't seem to be clear on how to reproduce this issue at the moment. As described above I am running this in en environment that has two vCenter servers that, for the most part, seem to be based on the same build and are both using tag assignments, but the one with more tag assignments is OK and the one with fewer tag assignments is not ok.
Regardless, the steps to reproduce the behavior are:
The exact command being run (vCenter name obfuscated) is:
Expected behavior The document should be produced with no errors.
Screenshots If applicable, add screenshots to help explain your problem.
System (please provide the following information about the system from which you are trying to generate a report):
Additional context If you dig in to some of the debugging in VS Code, the specific PScribo command it is failing on is Get-HtmlTable:
The report runs ok if you output to text instead of word or HTML.