'Timeout while executing Powershell script

I don't have much experience with Powershell yet, I'm looking for a solution for my script. I work with a process automation platform called "Firestart" and in it you can run powershell scripts.

The purpose of the script: to read a single cell from an .xlsx file.

Right now I am trying to run a script with this application and then the script keeps running for 10 minutes. Because of this I automatically get a Timeout error which is logical. If I run this script on the same server in Powershell, I get the desired outout within 1 seconds.

It might be an problem of the application itself, but maybe someone can review my script.

Script:

$objExcel = New-Object -ComObject Excel.Application 
$ExcelFile = '#.xlsx file'
$WorkBook = $objExcel.Workbooks.Open($ExcelFile)
$workbook.sheets.item(1).activate()
$WorkbookTotal=$workbook.Worksheets.item(1)
$value = $WorkbookTotal.Cells.Item(10, 2)

return $value.Text


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source