Tinus EngOps Wiki

Logo

OpsaC - Operating as PowerShell code

Links

Home

IT-Wiki

PowerShell Blog

PowerShell Index

PowerShell Search

Additional Websites

View my GitHub Profile

View my GitHub Gists

View my Codeberg Page

View my Photo Website

Visual Studio Code

published: February 6, 2021 author: Tinu tags: PowerShell categories: Visual-Studio-Code


Table of Contents

VSCode offline Installation

Download Source

During the installation, select Additional Tasks, Other and acivate:

  • Add “Open with Code” action to Windows Explorer file context menu
  • Add “Open with Code” action to Windows Explorer directory context menu
  • Add to PATH (available after restart)

Extensions for the Visual Studio Code

The Marketplace offers a variety of extensions for VSCode.

In my opinion, the following extensions are necessary:

  • PowerShell Language Support for Visual Studio Code
  • Markdown All in One
  • Git Extension Pack
  • Excel Viewer
  • Python
  • Jupyter Extension for Visual Studio Code

Offline Installation

Download the desired extension and copy it to the target server.

Set-Location "$($env:ProgramFiles)\Microsoft VS Code\bin"
$Extensions = 'D:\Sources\VSCode' 
foreach($item in (get-childitem $Extensions -Filter '*.vsix')){
     code --install-extension $item.FullName 
}

The extensions are installed in $env:USERPROFILE.vscode\extensions.

ISE Experience

After installing the PowerShell Language Support for Visual Studio Code Extension, select the ISE color theme with Ctrl. + K + T, PowerShell ISE.

Customize ISE Experience

Press Ctrl + Shift + P, Preferences: Open Settings (JSON) complete with the following entries:

{
    "terminal.integrated.shell.windows": "C:\\Program Files\\PowerShell\\7\\pwsh.exe",
    "git.ignoreMissingGitWarning": true,
    "workbench.sideBar.location": "left",
    "workbench.statusBar.visible": true,
    "workbench.activityBar.visible": true,
    "editor.minimap.enabled": false,
    "editor.renderControlCharacters": true,
    "explorer.confirmDelete": false,
    "gitlens.advanced.messages": {
        "suppressShowKeyBindingsNotice": true
    },
    "workbench.startupEditor": "newUntitledFile",
    "editor.tabCompletion": "on",
    "powershell.integratedConsole.focusConsoleOnExecute": true,
    "powershell.integratedConsole.showOnStartup": false,
    "files.defaultLanguage": "powershell",
    "files.autoSave": "onWindowChange",
    "git.autofetch": true,
    "git.confirmSync": false,
    "editor.largeFileOptimizations": false,
    "workbench.colorTheme": "Visual Studio Dark",
    "terminal.integrated.rendererType": "dom",
    "editor.codeActionsOnSave": null,
    "python.languageServer": "Pylance",
}

VS Code Color Customization

To customize the colors of your vscode, paste this settings into the settings.json:

    "workbench.colorCustomizations": {
        "titleBar.activeBackground": "#4249a8",
        "titleBar.inactiveBackground": "#a8ace6",
        "titleBar.activeForeground": "#fff",
        "titleBar.inactiveForeground": "#c5c3c3",
        "statusBar.foreground": "#fff",
        "statusBar.background": "#4249a8"
    }

How to replicate the ISE experience in Visual Studio Code

VSCode Commands

code --extensions-dir
     Set the root path for extensions.
code --list-extensions
     List the installed extensions.
code --show-versions
     Show versions of installed extensions, when using --list-extension.
code --install-extension ( | )
     Installs an extension.
code --uninstall-extension ( | )
     Uninstalls an extension.
code --enable-proposed-api ()
     Enables proposed API features for extensions. Can receive one or more extension IDs to enable individually.

See also

Visual Studio Code on Docs.


← Previous Post ◇ [ Top ] ◇ Copyright © 2024 by tinuwalther ◇ [ Blog ] ◇ Next Post →