Not sure why yours is empty, this is what mine returns.
foreach($verb in $file.verbs()){$verb.name}
&Open
Run as &administrator
&Open with Sublime Text 2
Open w&ith Code
&Pin to Start
Scan for Viruses...
Share
Restore previous &versions
Cu&t
&Copy
Create &shortcut
&Delete
Rena&me
P&roperties
Hello, I see 3 empty entries in your reply aswell, I think you have not understood the question properly (between Pin to start<>Scan for Viruses and Restore …<>Cut). Also, no Send to> entry on your output.
Here is a screenshot of the context menu, and what I am missing (Notice the empty space between Restore previous entry and Cut) example — ImgBB
&Open
Run as &administrator
&Pin to Start
Edit with &Notepad++
Share
Scan with Sophos Anti-&Virus
&Add to archive...
Add &to "notepad.rar"
Compress and email...
Compress to "notepad.rar" and email
Restore previous &versions
Cu&t
&Copy
Create &shortcut
&Delete
Rena&me
P&roperties
But actually even this is just an example, I want to click in the context menu of a Bluetooth PAN device, which hast one single entry: Connect to Network>Connect to Adhoc Network
Right-Click context menus are just running commands in the background. Look at HKEY_CLASSES_ROOT*\shell and Computer\HKEY_CLASSES_ROOT*\shellex and find the command that is executed and then write code to execute that versus parsing the actual menu.
#Open with VSCode command
PS C:\Users\rs> Get-ItemProperty -LiteralPath "Registry::HKEY_CLASSES_ROOT\*\shell\VSCode\Command" | Select -ExpandProperty '(default)'
"C:\Users\rs\AppData\Local\Programs\Microsoft VS Code\Code.exe" "%1"
Thanks, the entries to some of the missing items seem to be there, but not for the area I am looking for. Searching through the registry I havent found any entries leading to the network connection menu item.
For clarity, this is the action I want to trigger in the end:
Maybe you asked the wrong question. What is it actually what you want to achieve? I assume you want to connect to a perticular network. You might search for this.
We did search/pair/set up Bluetooth PAN network service using the bluetooth API in windows. But neither the Windows Bluetoot or Socket API, netsh, COM objects nor any 3rdparty tools give you possibility to actually “trigger” the connection (can be done by right click->connect using->adhoc network, see picture above). Without pressing this button the connection is down.
So our idea was to trigger that particular context menu entry using powershell, but it did not work out. The only thing thats worked is opening the window and emulating keypresses with powershell, which is obviously not that nice. Triggering with Verb.DoIt() is not possible, nor have we found any other way.
For me this looks more like a task for a software developer than for a Powershell scripter. You may ask in a little more crouded place for developers like StackOverflow.
Well, we already tried on stackoverflow. There is no programmatic way to trigger this event, Microsoft does not offer a public API.
So this is why we thought of a script solution, just simulating that click on the context menu or on the window tab, or triggering the event behind. That should very well be a script job.