Skip to content

Using -comObject in pwsh7 is extremly slow compaired to powershell 5.1 #36944

Closed
@skippernl

Description

@skippernl

Hi I was pointed in this direction by the pwsh7 team.

I have a powershell script that takes the config of a firewall and creates an excel document from it.
On powershell 5.1 this takes about 5 minutes depending on the size of the config.
On powershell 7 this takes more that 2 hours.
The main function that slows down is writing to excel
$Excel = New-Object -ComObject Excel.Application
$Excel.Visible = $false
$workbook = $excel.Workbooks.Add()
$TocSheet = $workbook.Worksheets.Item(1)
$MainSheet = $workbook.Worksheets.Add()
$TocSheet.Name = "ToC"

Commenting the firstline out (The new-object)
Makes the script run on pwsh7 in 49 seconds to 2 minutes and 35 seconds in powershell 5.

As the main function of this script is converting a config file to excel tabs it is higly depending on the -ComObject.

Full script can be found here
https://github.com/skippernl/Fortigate2Excel

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions