Visual Studio Code Extension
Learn about the Visual Studio Code extension for Universal.
PowerShell Universal can be managed with the PowerShell Universal Visual Studio Code extension. It allows you to connect to a local Universal instance and manage APIs, dashboards and scripts.
Installation
You can download the extension from the Visual Studio Marketplace. You can also download the extension from within the Visual Studio Code extension pane. Search for PowerShell Universal and click Install.
![](https://docs.powershelluniversal.com/~gitbook/image?url=https%3A%2F%2F1373299915-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F8F6PrkNTG8Y34hADzKOL%252Fuploads%252Fgit-blob-59547ff78bd5ac3cd02929df8560069433bf5e1b%252Fimage%2520%28278%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=4ae8c017&sv=1)
Configuration
The extension will prompt you for the URL and App Token used to connect to your PowerShell Universal instance. Follow the instructions within the extension when it starts up.
Configure From PowerShell Universal
You can configure the extension by navigating to your PowerShell Universal admin console and then logging in. Navigate to Settings \ Configurations and click Edit with VS Code. A new app token will be generated, and the URL will be set automatically.
![](https://docs.powershelluniversal.com/~gitbook/image?url=https%3A%2F%2F1373299915-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F8F6PrkNTG8Y34hADzKOL%252Fuploads%252Fgit-blob-da3c1800ae9c2afd94f5f5c801d00ac704bdde08%252Fimage%2520%2843%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=e9a167c&sv=1)
Configure Multiple Connections
You can configure multiple connections by using the Connections setting. Click the Add Connection button to open Settings.
![](https://docs.powershelluniversal.com/~gitbook/image?url=https%3A%2F%2F1373299915-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F8F6PrkNTG8Y34hADzKOL%252Fuploads%252Fgit-blob-db343d4be49fdd1680ecc8db010192815b846343%252Fimage%2520%28213%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=3d7bde04&sv=1)
Next, click the Edit settings.json link underneath the Connections setting.
![](https://docs.powershelluniversal.com/~gitbook/image?url=https%3A%2F%2F1373299915-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F8F6PrkNTG8Y34hADzKOL%252Fuploads%252Fgit-blob-21bf03b20ae17b66fd48b30cd8390c35f9e7af30%252Fimage%2520%28263%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=31ffacc8&sv=1)
The connections array can have zero to many connections. You can provide names for each connection.
Once you have defined a connection, you can connect to that instance by clicking the Connect to Instance button within the Connections tree view.
![](https://docs.powershelluniversal.com/~gitbook/image?url=https%3A%2F%2F1373299915-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F8F6PrkNTG8Y34hADzKOL%252Fuploads%252Fgit-blob-ddebc78f76fae8e6acdf1b6c25c0f8d4551dc1d4%252Fimage%2520%28436%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=2795e548&sv=1)
Features
The PowerShell Universal extension adds a new activity pane panel for PowerShell Universal. It has the following sections.
APIs
You can manage APIs with the extension. You will see a list of APIs. You can click the Open endpoints.ps1
button to view the endpoints file and add new endpoints. Clicking the refresh button will reload any endpoints you add. You can click the Insert Invoke-RestMethod to Console
to add a call to the endpoint to the PowerShell Integrated Console.
![](https://docs.powershelluniversal.com/~gitbook/image?url=https%3A%2F%2F1373299915-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F8F6PrkNTG8Y34hADzKOL%252Fuploads%252Fgit-blob-80e767ac01d0fd9d473741e99d9db87b943e2828%252Fimage%2520%28392%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=dbfc8bfe&sv=1)
Apps
You can manage apps with the extension. You will see a list of apps underneath this section. You can open the dashboards.ps1 script, open a single app's script, restart an app and view apps.
![](https://docs.powershelluniversal.com/~gitbook/image?url=https%3A%2F%2F1373299915-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F8F6PrkNTG8Y34hADzKOL%252Fuploads%252Fgit-blob-41e2dc30d38bb38be786fd82651d201340a57c83%252Fimage%2520%28492%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=53d956d&sv=1)
View Dashboard Logs
You can view dashboard logs by right clicking on the dashboard and clicking View Logs. They will open in a new tab.
![](https://docs.powershelluniversal.com/~gitbook/image?url=https%3A%2F%2F1373299915-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F8F6PrkNTG8Y34hADzKOL%252Fuploads%252Fgit-blob-bf4c3d8ed126895c0d943f185d52b6d0c5fb70fe%252Fimage%2520%28107%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=9e43465b&sv=1)
Scripts
You can manage scripts with the extension. You will see a list of available scripts underneath this section. You can edit the scripts.ps1, edit an individual script and run scripts. When running scripts, you will receive feedback about the status of the script. Scripts with parameters are not supported in VS Code. You can still run them in PowerShell Universal.
![](https://docs.powershelluniversal.com/~gitbook/image?url=https%3A%2F%2F1373299915-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F8F6PrkNTG8Y34hADzKOL%252Fuploads%252Fgit-blob-0370e889551e469771f8b3f9512bb9c595184f20%252Fimage%2520%28346%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=d258ec40&sv=1)
Debugging
The Administrator role is required for debugging scripts remotely.
As of PowerShell Universal v4.2, you can debug scripts remotely with the PowerShell Universal extension. To enable remote debugging, you will need to set the debugger environment in the settings. This is the process that will be started and will load PowerShell Editor Services.
When connected to your PowerShell Universal instance, you can expand Platform \ Processes and then locate the process you wish to debug. If you use the Wait-Debugger
cmdlet in your scripts, they will be displayed within the process and runspace drop down. Click the Attach Runspace command to begin debugging your script.
![](https://docs.powershelluniversal.com/~gitbook/image?url=https%3A%2F%2F1373299915-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F8F6PrkNTG8Y34hADzKOL%252Fuploads%252Fgit-blob-3ba0175260f236b4dd46cc16d777361570a0143c%252Fimage.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=24428501&sv=1)
Sample Browser
The sample browser can be used to insert samples from the PowerShell Universal Sample Repository into your PowerShell Universal instance. Just save the files it updates and your PowerShell Universal system will reflect the changes.
Settings
Settings can be found within the Visual Studio Code Settings dialog. You can open the settings dialog by press Ctrl+,
PowerShell Universal settings can be found under Extensions \ PowerShell Universal.
App Token
The App Token is used for communicating with the PowerShell Universal management API. You can create an App Token manually by navigating to Security \ Tokens within the PowerShell Universal admin console.
You can also automatically configure an App Token by click Edit with VS Code within Settings \ Configurations.
Check Modules
The extension will check the version of the Universal and UnviersalDashboard PowerShell modules found on the system. If they aren't installed or are not the latest version, new versions will be installed.
Connections
The Connections array allow for defining multiple PowerShell Universal instance connections.
Samples Directory
This is the directory to store the PowerShell Universal samples.
Sync Samples
Whether to download samples from GitHub so they are available within the samples browser.
Url
The URL of the PowerShell Universal service. This should be the root URL, such as http://localhost:5000
. This will be set automatically when clicking Edit in VS Code.
Last updated