I wouldn't use Sitecore Powershell Extensions for this. SPE doesn't have anything for interacting with the clipboard and also doesn't execute custom JS from scripts (yet!).
Additionally, there already exists a command within Sitecore for copying the path to the clipboard, so all you need to do is assign it to a new button in the context menu.
John West has blogged about this here - https://community.sitecore.net/technical_blogs/b/sitecorejohn_blog/posts/repost-add-a-command-to-the-sitecore-item-context-menu - but to summarise:
Create a new item of template System/Menus/Menu item
under the item /Sitecore/Content/Applications/Content Editor/Context Menues/Default
in the Core
database.
This item should have the message field set to clipboard:copypathtoclipboard(id=$Target)
.
The command should then be executable from the context menu.
This message actually invokes a command, which is specified in Commands.config
as Sitecore.Shell.Framework.Commands.Clipboard.CopyPathToClipboard,Sitecore.Kernel
.
However, this command provided by Sitecore operates in Internet Explorer only. It specifically checks the browser and hides the menu option if it fails:
if (context.Items.Length != 1 || !UIUtil.IsIE())
return CommandState.Hidden;
This is because traditionally only IE had support for interfacing with the OS clipboard. Other browsers had to make use of Flash solutions.
However, there looks to be more modern solutions for handling clipboard usage in other browsers, if that is important to you. For instance there is this library - https://github.com/zenorocha/clipboard.js
If supporting other browsers is important, you will need to implement your own custom command. I would look at the source for the CopyPathToClipboard
type and implement something similar that executes your custom JS when executed.