PowerShell / vscode-powershell

Provides PowerShell language and debugging support for Visual Studio Code
https://marketplace.visualstudio.com/items/ms-vscode.PowerShell
MIT License
1.69k stars 480 forks source link

ISE Add-Ons #2069

Open jobasque opened 5 years ago

jobasque commented 5 years ago

Powershell ISE Addons are small blocks of code that are executed and have a context menu item that opens for users executing the code. Useful for administration teams to use ISE as a toolbox with prebuilt functions.

mattmcnabb commented 5 years ago

Maybe take a look at Register-EditorCommand. This allows you to execute arbitrary scriptblocks from keyboard shortcuts.

Here's an example I mocked up a while back:

https://twitter.com/mcnabbmh/status/734947368093814784

rjmholt commented 5 years ago

@jobasque you've described what ISE addons are, but what are your desires for functionality in the PowerShell extension?

ISE addons are very specific to the ISE and particularly hook into WPF to generate their UI. VSCode runs on Electron, which is node-based (not .NET), and thus has no WPF APIs; they are entirely different technology ecosystems. Also, from the perspective of the PowerShell extension, our ability to generate new UI is limited by VSCode APIs.

One ISE extension that does accomplish this is the Azure Automation ISE addon, which is specifically designed to work with both the ISE and as an out-of-process window to be used alongside VSCode.

Otherwise, some possibilities are:

If these don't cover the scenario you have in mind, please let us know.

jobasque commented 5 years ago

Thanks all for help -- the last thing I need is a way to reload the VSCode window programmatically from within powershell (or some other method to re-apply the settings updated in settings.json file). My 3 priorities for moving from ISE to VSCODE -Custom global profile (server-wide) RESOLUTION: c:\windows\system32\windowsPowershell\Microsoft.VSCode_profile.ps1 -ISE ADD-ON Menu options RESOLUTION: custom command palette commands (define functions in global profile and register-editorcommand, define shortcut key to show custom commands) -Global settings.json file Possible solution(?): I planned to programmatically copy the settings.json file via the global profile.ps1 which is called as the vscode is launched, however I do not have a way to programmatically reload the vscode window. I found an article on another site which referenced some vscode built in commands https://code.visualstudio.com/api/references/commands

and particularly this command: vscode.commands.executeCommand('workbench.action.reloadWindow');

However I need a way to call this from powershell language if someone could assist me with this, or if there is another native command that I can call/invoke from a profile ps1 to reload the VSCode window and reapply settings.json.

Obviously also there would be some logic to determine the user profile location for user running VScode to find their settings.json file, and also a way to flag that the vscode restart is intitialized to prevent an infinite respawn loop which I will have to write.

Alternatively, a global settings.json file would be even better. Thanks all

Thank you

TylerLeonhardt commented 5 years ago

@jobasque I feel like you might want something similar to Settings Sync but private.

Is that correct?

jobasque commented 5 years ago

Hey Tyler, that's correct. But due to security needs of customer, settings would need to be managed internally on a domain joined machine or via a global settings.json file. I also thought of a way to use the profile powershell to check the contents of the settings.json file and if required settings were missing, I could simply display a warning text and then force the vscode process to close. Would you happen to know best method to use to force close the vscode executable within powershell profile script?

Thanks for quick replies. Josh

Joshua Basquez Consultant | Microsoft Messaging Business Productivity and Public Sector Oklahoma City, OK Joshua.Basquez@microsoft.com


From: Tyler James Leonhardt notifications@github.com Sent: Wednesday, July 10, 2019 8:09:56 PM To: PowerShell/vscode-powershell vscode-powershell@noreply.github.com Cc: Josh Basquez Joshua.Basquez@microsoft.com; Mention mention@noreply.github.com Subject: Re: [PowerShell/vscode-powershell] ISE Add-Ons (#2069)

@jobasquehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fjobasque&data=02%7C01%7CJoshua.Basquez%40microsoft.com%7C9d682ded8bbe461b912408d7059c7cdf%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636984041977630169&sdata=dYj0GyD%2BaEFVuUElffAzwuT%2FuYw6Xc9JX1cvtR1FrN4%3D&reserved=0 I feel like you might want something similar to Settings Synchttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmarketplace.visualstudio.com%2Fitems%3FitemName%3DShan.code-settings-sync&data=02%7C01%7CJoshua.Basquez%40microsoft.com%7C9d682ded8bbe461b912408d7059c7cdf%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636984041977630169&sdata=LajY6ee12AiMq7Nx6tndRNHOe0Db1W6SY8G70mp%2FG9k%3D&reserved=0 but private.

Is that correct?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FPowerShell%2Fvscode-powershell%2Fissues%2F2069%3Femail_source%3Dnotifications%26email_token%3DAMREYYINUKQTA3PWX4IJWPLP62B6JA5CNFSM4H6M4JC2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZVFVOQ%23issuecomment-510286522&data=02%7C01%7CJoshua.Basquez%40microsoft.com%7C9d682ded8bbe461b912408d7059c7cdf%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636984041977630169&sdata=OZUy0N6E4W8bmwN4td52SNSwpF6aYuTvUFsK1ybMpK4%3D&reserved=0, or mute the threadhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAMREYYPCM6S3GRJJO3ERJIDP62B6JANCNFSM4H6M4JCQ&data=02%7C01%7CJoshua.Basquez%40microsoft.com%7C9d682ded8bbe461b912408d7059c7cdf%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636984041977630169&sdata=NXV9Rw3kf1sb1Zs6CpE%2B5eW2BMEI6A%2BiSEOfu3nTf5o%3D&reserved=0.