Is there a way to use PowerShell ISE Add-ons on Visual Studio Code?

223 Views Asked by At

I've created some Add-ons on PowerShell ISE to connect to some services like: Office 365, Exchange Online, Sharepoint Online, PowerCLI, Dell Storage, etc.

I am now trying to migrate from PowerShell ISE to Visual Studio Code and I can't find a way to use Add-ons there. Any tips?

2

There are 2 best solutions below

0
On BEST ANSWER

Finally I found a solution! (Sorry, I'll correct my mistake and post the solution here and not only the link...)

Just use "Register-EditorCommand" cmdlet.

On your profile script file, add something like this:

Function Connect_PowerCLI {
    $VMwareCredential = Get-Credential
    $ESXiHosts = @("esxi01","esxi02","esxi03")
    $ESXiHosts | ForEach-Object {
        Connect-VIServer -Server $_ -Credential $VMwareCredential
    }
}
Register-EditorCommand -Name Connect_PowerCLI -DisplayName "Connect on all ESXi hosts using VMware PowerCLI" -Function Connect_PowerCLI

Configure your VSCode shortcut:

{
  "key": "shift+alt+s",
  "command": "PowerShell.ShowAdditionalCommands",
  "when": "editorTextFocus && editorLangId == 'powershell'"
}

Then, with Visual Studio Code opened, press SHIFT+ALT+S and select what you need to be executed.

Jeffery Hicks original post: https://jdhitsolutions.com/blog/powershell/5907/extending-vscode-with-powershell

0
On

Visual Studio Code has a completely different extensions model from the Powershell ISE and I would not expect the two to be compatible. You're best off finding VSCode extensions that fill in the functionality you're looking for.