Powershell – 脚本在阅读第一个Excel工作表后死机

我遇到了我的Powershell脚本的问题 – 它的意思是通过一系列的工作簿循环,但在第一个之后冻结。 任何想法为什么会发生这种情况?

$(for ($i=3; $i -le $wb.sheets.count; $i++){ $sh=$wb.Sheets.Item($i) $startCell = $sh.cells.item(1,2).EntireColumn.find("Application Name").Address() if($startCell -match '\$\w+\$(\d+)') { for($row=[int]$matches[1]+1; $sh.cells.item($row,2) -ne ""; $row++) { $apps = "" | Select appname,location,lob $apps.appname = $sh.Cells($row, 2).Value2 $apps.location = $sh.Cells($row, 10).Value2 $apps.lob = $sh.Name $apps } } })