When I use PowerShell, I only get one (Workbook3) of several window titles (Workbook1, Workbook2, Workbook3), but I want to get the entire list of all open Excel books. I am trying to use the following code:
[array]$Titles = Get-Process | Where-Object {$_.mainWindowTItle} |Foreach-Object {$_.mainwindowtitle}
ForEach ($item in $Titles){Write-Host $item}
UPD. (We get a list of books, but we don't see which ones only to read) If I open the book in read-only mode, it will not be visible in the output of the program. In the Task Manager this mark is in the name of the window.
$excel = [Runtime.Interopservices.Marshal]::
GetActiveObject('Excel.Application')
ForEach ( $wkb in $excel.workbooks ) {
$wkb.Name
}

