#Requires -RunAsAdministrator $ErrorActionPreference = 'Continue' $dte = New-Object -ComObject TcXaeShell.DTE.17.0 $dte.MainWindow.Visible = $true try { $dte.SuppressUI = $false } catch {} $dte.Solution.Open('C:\Users\tonycao\work\twincat3-auto-cli\TwinCAT_EL6695_Primary\TwinCATProject1.sln') Start-Sleep 25 $sm = $null for ($i = 0; $i -lt 20; $i++) { try { $sm = $dte.Solution.Projects.Item(1).Object; if ($sm) { break } } catch {} Start-Sleep 3 } if (-not $sm) { Write-Host 'no sysmgr'; exit 1 } foreach ($prefix in @('TIRT', 'TISM', 'TISY', 'TICC', 'TIDK')) { try { $it = $sm.LookupTreeItem($prefix) if ($it) { Write-Host "=== $prefix : $($it.Name) childcount=$($it.ChildCount) ===" for ($j = 1; $j -le [int]$it.ChildCount; $j++) { $ch = $it.Child($j) Write-Host " [$j] $($ch.Name) subtype=$($ch.ItemSubType)" } } } catch { Write-Host "$prefix : not found" } }