I have two windows Microsoft edge that have two tabs each. so I want to make PowerShell script when its run, the tab move to another tab in each edge.
-
Welcome to SO. SO has rules: [Provide MRE](https://stackoverflow.com/help/minimal-reproducible-example) --- [How to ask](https://stackoverflow.com/help/how-to-ask) --- [Don't ask](https://stackoverflow.com/help/dont-ask) --- [Proper Topic](https://stackoverflow.com/help/on-topic) --- [Why not upload images of code/errors?](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-errors-when-asking-a-question) --- [format your post properly](https://stackoverflow.com/help/formatting). What did you search for? What did you try? Show us your code. SO is not a coding service. – postanote Aug 01 '22 at 04:07
-
['powershell microsoft edge automation'](https://duckduckgo.com/?q=%27powershell+microsoft+edge+automation%27%27&t=h_&ia=web) – postanote Aug 01 '22 at 04:11
-
I suggest that you can refer to the script in [this link](https://www.reddit.com/r/PowerShell/comments/qaua94/comment/hpulesl/?utm_source=share&utm_medium=web2x&context=3) first. It can get the urls of Edge tabs. Then you can open the urls one by one in another Edge instance to "move" the tabs. – Yu Zhou Aug 02 '22 at 08:06
1 Answers
I can't see a simple way to do this (if I have correctly understood your question).
Even using:
ps msedge | where {$_.MainWindowTitle}
to get access to the actual Edge windows open on your system, the returned System.Diagnostics.Process
instances do not contain anything that will allow you to discern the specific URLs that are open such that they can be opened in the other Edge window.
On the rare chance that the msedge
instances themselves were started from the shell with URL(s) as their command line arguments, you could delve into WMI to pull them back out, close their processes and then open them again in Edge, which will add them as tabs to the other still existing Edge instance. However, I think it's quite unlikely that this is the case. So, moving on.
I found another question: [PowerShell get URL of Browser tab], that seems to be able to pull a URL from an active Chrome tab. As Edge and Chrome are both Chromium, I have a hunch that this will require minimal changes to get working in Edge. Once you have the URL, you can close the Edge instance that it's attached to, and then Start-Process msedge -ArgumentList $url
to 'move' it to the other open window, however, the linked question seems to only be able to pull the URL of the active tab - which doesn't help much if you have two tabs open, but it may be a start nonetheless.
Finally, I know your question is regarding a PowerShell script, but there are extensions that facilitate the merging of tabs as you describe. Not what you asked for but worth mentioning.

- 549
- 9
- 23