PoshCode Logo PowerShell Code Repository

Start-Selected by Bernd Kriszio 29 months ago
embed code: <script type="text/javascript" src="http://PoshCode.org/embed/1297"></script>download | new post

Usuallay I use this to start my browser with a URL in some PowerShell Script or retrieved by some Powershell Script. This is an ISE-Extension.

  1. #Hightlight the name of a file or URL and this will opened or shown in browser
  2. if ($PSVersionTable.BuildVersion.build -le 7000)
  3. {
  4.     # PowerShell V2 CTP3
  5.     function Start-Selected
  6.     {
  7.         $ed = $psise.CurrentOpenedFile.Editor
  8.         start $ed.SelectedText
  9.     }
  10. }
  11. else
  12. {
  13.     # PowerShell W7
  14.     function Start-Selected
  15.     {
  16.         $file = $psIse.CurrentPowerShellTab.Output.SelectedText
  17.         if ($file -eq '')
  18.         {
  19.             $file = $psise.CurrentFile.Editor.SelectedText
  20.         }
  21.         if ($file)
  22.         {
  23.             start $file
  24.         }    
  25.     }
  26. }
  27. #Set-CustomMenu "Start Selected" {Start-Selected} 'Ctrl+Shift+S'

Submit a correction or amendment below (
click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:


Remember me