How to make PowerShell $ie COM object reference new browser window
<p>I have a powershell script which logs in to a site and clicks on a link leading to an external site. When the link is clicked it opens in a new window and closes the original window. </p>

<p>This is an issue because I need to get access to the elements on the new page but am unable to perform any commands (such as getElementById) on the document because the $ie com object is still referencing the original window. Is there a way to tell the $ie com object to reference the new window that opens rather than the old window? any help is appreciated. Thank you</p>