skippernl / Fortigate2Excel

Parse a fortigate configurationfile and export it to Excel
GNU General Public License v3.0
34 stars 8 forks source link

Line 1101 You cannot call a method on a null-valued expression #8

Closed nkeegan339 closed 2 years ago

nkeegan339 commented 2 years ago

Windows 10 x64 running Powershell 7.2.2 x64, I get the following over and over again while the script runs:

InvalidOperation: C:\users\blah\Fortigate2Excel.ps1:1101 Line 1101 $excel.cells.item($row,$Column) = $Value You cannot call a method on a null-valued expression

The script completes but no actual output is produced.

Additional output is same error at lines 1595, 3244, 3250-3258

Running latest version of Fortigate2Excel.

skippernl commented 2 years ago

I will have a look when I get back. In what segment of the config file are the errors present? Can you post this segment (sanitize all ipadresses and other traceable data) so I can test the file.

nkeegan339 commented 2 years ago

I will try an additional smaller config and then run the problem config with a focus on where the issue first presents and post up that configuration.

skippernl commented 2 years ago

Hi do you have an update for me? Line 1101 is used for creating the excel table and is used just about anywhere. Line 1595 Has to do with SNMP and if the sheet is empty that could account for the error. Line 3244 is the table of contents The other lines are main information from the fortigate.

I have run multiple own configurations and cannot reproduce the issue reported.

nkeegan339 commented 2 years ago

Here is what I'm seeing as the root error:

Timezone file imported. Time-zone names will be used instead of ID. FortiNet ISDB file imported. Database names will be used instead of ID. PS C:\Users\blah\Scratch and Cut\Fortigate2Excel-master> TerminatingError(New-Object): "Retrieving the COM class factory for component with CLSID {00000000-0000-0000-0000-000000000000} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))." New-Object : Retrieving the COM class factory for component with CLSID {00000000-0000-0000-0000-000000000000} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)). At C:\Users\blah\Scratch and Cut\Fortigate2Excel-master\Fortigate2Excel.ps1:1862 char:10

nkeegan339 commented 2 years ago

Trying again with PS version 7.2.2

PS C:\Users\nate.keegan\Scratch and Cut\Fortigate2Excel-master> TerminatingError(New-Object): "Retrieving the COM class factory for component with CLSID {00000000-0000-0000-0000-000000000000} failed due to the following error: 80040154 Class not registered (0x80040154 (REGDB_E_CLASSNOTREG))."

New-Object: C:\Users\blammo\Scratch and Cut\Fortigate2Excel-master\Fortigate2Excel.ps1:1862 Line | 1862 | $Excel = New-Object -ComObject Excel.Application | ~~~~~~~~~~~ | Retrieving the COM class factory for component with CLSID {00000000-0000-0000-0000-000000000000} failed due to the following error: 80040154 Class not registered (0x80040154 (REGDB_E_CLASSNOTREG)).

New-Object: C:\Users\blammo\Scratch and Cut\Fortigate2Excel-master\Fortigate2Excel.ps1:1862 Line | 1862 | $Excel = New-Object -ComObject Excel.Application | ~~~~~~~~~~~ | Retrieving the COM class factory for component with CLSID {00000000-0000-0000-0000-000000000000} | failed due to the following error: 80040154 Class not registered (0x80040154 (REGDB_E_CLASSNOTREG)).

skippernl commented 2 years ago

This message seems to indicate that the com object for excel has not registerd. You may try to repair/reinstall excel on that machine.

nkeegan339 commented 2 years ago

Ah, gotcha...was thinking Excel module is embedded, I'm on a web only 365 system, will install Excel and that should take care of it.