Unable to write applescript to focus a session by ID
I am trying to write an applescript script that given a specific session ID, causes that session to steal focus. I tried my luck writing a basic starter:
tell application "iTerm"
repeat with aWin in windows
repeat with aSession in sessions
end repeat
end repeat
end tell
but I get stopped right there because iTerm2 complains: "iTerm got an error: Can’t get every session.".
Am I doing something wrong? Is this a problem with the deprecated AppleScript engine?
Thanks in advance for your help!
James