You Cannot Call A Method On A Null-valued Expression. (blank Report)
Bug description
When using infolevel FortiCare 1, you may encounter the error "You cannot call a method on a null-valued expression." This results in an empty report. This issue has been tested on two identical firewalls, and the only difference between them is that the report is working on the firewall where the FortiCare Support is registered.
Firewall model and firmware
- Firewall model: Fortinet FortiGate 60F
- Firewall firmware: v7.4.5 build2702 (Mature)
Licensing
Both firewalls are unlicensed, as they are used as lab devices.
Command-line input
The following command was used to reproduce the issue:
New-AsBuiltReport -Report Fortinet.FortiGate -Target A.B.C.D -Credential $Credentials -Format Html -OutputFolderPath '.\output\' -ReportConfigFilePath .\ReportConfig.json -AsBuiltConfigFilePath .\AsBuiltConfig.json -Verbose
Steps to reproduce
- Ran the above command.
Additional information
ReportConfig.json
The ReportConfig.json file used in this test can be found here: ReportConfig.json
Verbose log
The verbose log output is as follows:
VERBOSE: Loading As Built Report configuration from '.\AsBuiltConfig.json'.
VERBOSE: Populating RepositorySourceLocation property for module AsBuiltReport.Core.
VERBOSE: Loading module from path 'C:\Users\njoo\Documents\PowerShell\Modules\AsBuiltReport.Core\1.4.3\AsBuiltReport.Core.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module AsBuiltReport.Fortinet.FortiGate.
VERBOSE: Loading module from path 'C:\Users\njoo\Documents\PowerShell\Modules\AsBuiltReport.Fortinet.FortiGate\0.4.1\AsBuiltReport.Fortinet.FortiGate.psm1'.
VERBOSE: Loading AsBuiltReport.Fortinet.FortiGate report configuration file from path '.\ReportConfig.json'.
VERBOSE: Setting report filename to 'Fortinet FortiGate As Built Report'.
VERBOSE: Populating RepositorySourceLocation property for module AsBuiltReport.Core.
VERBOSE: Loading module from path 'C:\Users\njoo\Documents\PowerShell\Modules\AsBuiltReport.Core\1.4.3\AsBuiltReport.Core.psm1'.
WARNING: [ 12:51:02:026 ] [ Module ] - AsBuiltReport.Core 1.4.3 is currently installed.
VERBOSE: [ 12:51:02:410 ] [ Document ] - Document 'Fortinet FortiGate As Built Report' processing started.
VERBOSE: [ 12:51:02:424 ] [ Document ] - Please wait while the Fortinet FortiGate As Built Report is being generated.
VERBOSE: [ 12:51:02:424 ] [ Document ] - Executing report style script from path 'C:\Users\njoo\Documents\PowerShell\Modules\AsBuiltReport.Core\1.4.3\AsBuiltReport.Core.Style.ps1'.
VERBOSE: [ 12:51:02:437 ] [ Document ] - Setting global document options.
VERBOSE: [ 12:51:02:438 ] [ Document ] - Enabling section/heading numbering.
VERBOSE: [ 12:51:02:438 ] [ Document ] - Setting default font(s) to 'Segoe Ui'.
VERBOSE: [ 12:51:02:439 ] [ Document ] - Setting page top margin to '25.05'mm.
VERBOSE: [ 12:51:02:440 ] [ Document ] - Setting page right margin to '25.05'mm.
VERBOSE: [ 12:51:02:441 ] [ Document ] - Setting page bottom margin to '25.05'mm.
VERBOSE: [ 12:51:02:441 ] [ Document ] - Setting page left margin to '25.05'mm.
VERBOSE: [ 12:51:02:442 ] [ Document ] - Setting page size to 'A4'.
VERBOSE: [ 12:51:02:442 ] [ Document ] - Setting page orientation to 'Portrait'.
VERBOSE: [ 12:51:02:443 ] [ Document ] - Setting page height to '297'mm.
VERBOSE: [ 12:51:02:444 ] [ Document ] - Setting page width to '210'mm.
VERBOSE: [ 12:51:02:445 ] [ Document ] - Setting document style 'Title'.
VERBOSE: [ 12:51:02:445 ] [ Document ] - Setting document style 'Title2'.
VERBOSE: [ 12:51:02:446 ] [ Document ] - Setting document style 'Title3'.
VERBOSE: [ 12:51:02:447 ] [ Document ] - Setting document style 'Heading1'.
VERBOSE: [ 12:51:02:448 ] [ Document ] - Setting document style 'Heading2'.
VERBOSE: [ 12:51:02:449 ] [ Document ] - Setting document style 'Heading3'.
VERBOSE: [ 12:51:02:449 ] [ Document ] - Setting document style 'Heading4'.
VERBOSE: [ 12:51:02:450 ] [ Document ] - Setting document style 'NOTOCHeading4'.
VERBOSE: [ 12:51:02:451 ] [ Document ] - Setting document style 'Heading5'.
VERBOSE: [ 12:51:02:452 ] [ Document ] - Setting document style 'NOTOCHeading5'.
VERBOSE: [ 12:51:02:453 ] [ Document ] - Setting document style 'Heading6'.
VERBOSE: [ 12:51:02:454 ] [ Document ] - Setting document style 'NOTOCHeading6'.
VERBOSE: [ 12:51:02:455 ] [ Document ] - Setting document style 'NOTOCHeading7'.
VERBOSE: [ 12:51:02:456 ] [ Document ] - Setting document style 'Normal'.
VERBOSE: [ 12:51:02:457 ] [ Document ] - Setting document style 'Header'.
VERBOSE: [ 12:51:02:458 ] [ Document ] - Setting document style 'Footer'.
VERBOSE: [ 12:51:02:459 ] [ Document ] - Setting document style 'TOC'.
VERBOSE: [ 12:51:02:460 ] [ Document ] - Setting document style 'TableDefaultHeading'.
VERBOSE: [ 12:51:02:463 ] [ Document ] - Setting document style 'TableDefaultRow'.
VERBOSE: [ 12:51:02:464 ] [ Document ] - Setting document style 'Critical'.
VERBOSE: [ 12:51:02:465 ] [ Document ] - Setting document style 'Warning'.
VERBOSE: [ 12:51:02:466 ] [ Document ] - Setting document style 'Info'.
VERBOSE: [ 12:51:02:467 ] [ Document ] - Setting document style 'OK'.
VERBOSE: [ 12:51:02:468 ] [ Document ] - Setting document style 'Caption'.
VERBOSE: [ 12:51:02:469 ] [ Document ] - Setting table style 'TableDefault'.
VERBOSE: [ 12:51:02:470 ] [ Document ] - Setting table style 'Borderless'.
VERBOSE: [ 12:51:02:471 ] [ Document ] - Processing document header started.
VERBOSE: [ 12:51:02:471 ] [ Document ] - Processing paragraph 'Fortinet FortiGate As Built Report -[..]'.
VERBOSE: [ 12:51:02:473 ] [ Document ] - Processing document header completed.
VERBOSE: [ 12:51:02:473 ] [ Document ] - Processing document footer started.
VERBOSE: [ 12:51:02:474 ] [ Document ] - Processing paragraph 'Page <!# PageNumber #!>'.
VERBOSE: [ 12:51:02:475 ] [ Document ] - Processing document footer completed.
VERBOSE: [ 12:51:02:476 ] [ Document ] - Processing blank line.
VERBOSE: [ 12:51:02:477 ] [ Document ] - Processing image 'AsBuiltReport Logo'.
VERBOSE: [ 12:51:02:479 ] [ Document ] - Processing blank line.
VERBOSE: [ 12:51:02:480 ] [ Document ] - Processing paragraph 'Fortinet FortiGate As Built Report'.
VERBOSE: [ 12:51:02:481 ] [ Document ] - Processing blank line.
VERBOSE: [ 12:51:02:481 ] [ Document ] - Processing paragraph 'Easi'.
VERBOSE: [ 12:51:02:482 ] [ Document ] - Processing blank line.
VERBOSE: [ 12:51:02:483 ] [ Document ] - Processing table 'Cover Page'.
VERBOSE: [ 12:51:02:486 ] [ Document ] - Processing page break.
VERBOSE: [ 12:51:02:486 ] [ Document ] - Processing table of contents 'Table of Contents'.
VERBOSE: [ 12:51:02:487 ] [ Document ] - Processing page break.
VERBOSE: [ 12:51:02:636 ] [ Document ] - Connect to A.B.C.D : FGT60F (FGT60FXXXXXXXXX)
VERBOSE: [ 12:51:02:664 ] [ Document ] - Processing section 'FortiFuture-FW2 Configuration' started.
VERBOSE: [ 12:51:02:665 ] [ Document ] - Processing paragraph 'The following provides as-built docu[..]'.
VERBOSE: [ 12:51:02:666 ]<br/>
**Q&A: You cannot call a method on a null-valued expression. (blank report)**
**Q: What is the error "You cannot call a method on a null-valued expression."?**
A: The error "You cannot call a method on a null-valued expression." is a common error in PowerShell that occurs when you try to call a method on an object that is null or empty.
**Q: What causes this error in the context of AsBuiltReport?**
A: In the context of AsBuiltReport, this error occurs when the FortiCare settings information is not available or is null, causing the report to fail and resulting in an empty report.
**Q: How can I troubleshoot this issue?**
A: To troubleshoot this issue, you can try the following:
1. Check the FortiCare settings information on the firewall to ensure that it is correctly configured.
2. Verify that the FortiCare Support is registered on the firewall.
3. Check the verbose log output to see if there are any other errors or warnings that may be related to this issue.
4. Try running the report with the `-Verbose` parameter to get more detailed output.
**Q: How can I prevent this error from occurring?**
A: To prevent this error from occurring, you can try the following:
1. Ensure that the FortiCare settings information is correctly configured on the firewall.
2. Verify that the FortiCare Support is registered on the firewall.
3. Use the `-Verbose` parameter when running the report to get more detailed output and troubleshoot any issues that may arise.
**Q: What are the system requirements for running AsBuiltReport?**
A: The system requirements for running AsBuiltReport are:
* PowerShell 7.5.0 or later
* AsBuiltReport.Core 1.4.3 or later
* AsBuiltReport.Fortinet.FortiGate 0.4.1 or later
* FortiGate firmware v7.4.5 build2702 or later
**Q: How can I get help with AsBuiltReport?**
A: If you need help with AsBuiltReport, you can try the following:
1. Check the AsBuiltReport documentation and user guide for more information.
2. Search the AsBuiltReport GitHub repository for issues and solutions.
3. Contact the AsBuiltReport support team for assistance.
**Q: What are the known issues with AsBuiltReport?**
A: The known issues with AsBuiltReport include:
* #50: FortiCare settings information not available or null
**Q: How can I contribute to AsBuiltReport?**
A: If you would like to contribute to AsBuiltReport, you can try the following:
1. Check the AsBuiltReport GitHub repository for issues and solutions.
2. Submit a pull request with your changes.
3. Contact the AsBuiltReport support team for assistance.