Coder Social home page Coder Social logo

powershell / vscode-powershell Goto Github PK

View Code? Open in Web Editor NEW
1.7K 113.0 471.0 9.87 MB

Provides PowerShell language and debugging support for Visual Studio Code

Home Page: https://marketplace.visualstudio.com/items/ms-vscode.PowerShell

License: MIT License

PowerShell 8.77% TypeScript 90.78% C# 0.45%
visual-studio-code powershell extensions hacktoberfest

vscode-powershell's Introduction

logo PowerShell

Welcome to the PowerShell GitHub Community! PowerShell is a cross-platform (Windows, Linux, and macOS) automation and configuration tool/framework that works well with your existing tools and is optimized for dealing with structured data (e.g. JSON, CSV, XML, etc.), REST APIs, and object models. It includes a command-line shell, an associated scripting language, and a framework for processing cmdlets.

Windows PowerShell vs. PowerShell Core

Although this repository started as a fork of the Windows PowerShell codebase, changes made in this repository are not automatically ported back to Windows PowerShell 5.1. This also means that issues tracked here are only for PowerShell Core 6 and higher. Windows PowerShell specific issues should be reported with the Feedback Hub app, by choosing "Apps > PowerShell" in the category.

New to PowerShell?

If you are new to PowerShell and want to learn more, we recommend reviewing the getting started documentation.

Get PowerShell

You can download and install a PowerShell package for any of the following platforms.

Supported Platform Download (LTS) Downloads (stable) Downloads (preview) How to Install
Windows (x64) .msi .msi .msi Instructions
Windows (x86) .msi .msi .msi Instructions
Ubuntu 22.04 .deb .deb .deb Instructions
Ubuntu 20.04 .deb .deb .deb Instructions
Ubuntu 18.04 .deb .deb .deb Instructions
Ubuntu 16.04 .deb N/A N/A Instructions
Debian 10 .deb .deb .deb Instructions
Debian 11 .deb .deb .deb
CentOS 7 .rpm .rpm .rpm Instructions
CentOS 8 .rpm .rpm .rpm
Red Hat Enterprise Linux 7 .rpm .rpm .rpm Instructions
openSUSE 42.3 .rpm .rpm .rpm Instructions
Fedora 35 .rpm .rpm .rpm Instructions
macOS 10.13+ (x64) .pkg .pkg .pkg Instructions
macOS 11+ (arm64) .pkg .pkg .pkg Instructions
Docker Instructions

You can download and install a PowerShell package for any of the following platforms, which are supported by the community.

Platform Downloads (stable) Downloads (preview) How to Install
Arch Linux Instructions
Kali Linux .deb .deb Instructions
Many Linux distributions Snapcraft Snapcraft

You can also download the PowerShell binary archives for Windows, macOS, and Linux.

Platform Downloads (stable) Downloads (preview) How to Install
Windows 32-bit/64-bit 32-bit/64-bit Instructions
macOS (x64) 64-bit 64-bit Instructions
macOS (arm64) 64-bit 64-bit Instructions
Linux 64-bit 64-bit Instructions
Windows (ARM) 64-bit (preview) 64-bit Instructions
Raspbian (ARM) 32-bit/64-bit 32-bit/64-bit Instructions

To install a specific version, visit releases.

Upgrading PowerShell

For best results when upgrading, you should use the same install method you used when you first installed PowerShell. The update method will be different for each platform and install method. For more information, see Installing PowerShell.

Community Dashboard

Dashboard with visualizations for community contributions and project status using PowerShell, Azure, and PowerBI.

For more information on how and why we built this dashboard, check out this blog post.

Discussions

GitHub Discussions is a feature to enable free and open discussions within the community for topics that are not related to code, unlike issues.

This is an experiment we are trying in our repositories, to see if it helps move discussions out of issues so that issues remain actionable by the team or members of the community. There should be no expectation that PowerShell team members are regular participants in these discussions. Individual PowerShell team members may choose to participate in discussions, but the expectation is that community members help drive discussions so that team members can focus on issues.

Create or join a discussion.

Chat

Want to chat with other members of the PowerShell community?

There are dozens of topic-specific channels on our community-driven PowerShell Virtual User Group, which you can join on:

Add-ons and libraries

Awesome PowerShell has a great curated list of add-ons and resources.

Building the Repository

Linux Windows macOS
Instructions Instructions Instructions

If you have any problems building, consult the developer FAQ.

Build status of nightly builds

Azure CI (Windows) Azure CI (Linux) Azure CI (macOS) CodeFactor Grade
windows-nightly-image linux-nightly-image macOS-nightly-image cf-image

Downloading the Source Code

You can clone the repository:

git clone https://github.com/PowerShell/PowerShell.git

For more information, see working with the PowerShell repository.

Developing and Contributing

Please look into the Contribution Guide to know how to develop and contribute. If you are developing .NET Core C# applications targeting PowerShell Core, check out our FAQ to learn more about the PowerShell SDK NuGet package.

Also, make sure to check out our PowerShell-RFC repository for request-for-comments (RFC) documents to submit and give comments on proposed and future designs.

Support

For support, see the Support Section.

Legal and Licensing

PowerShell is licensed under the MIT license.

Windows Docker Files and Images

License: By requesting and using the Container OS Image for Windows containers, you acknowledge, understand, and consent to the Supplemental License Terms available on Docker Hub:

Telemetry

Please visit our about_Telemetry topic to read details about telemetry gathered by PowerShell.

Governance

The governance policy for the PowerShell project is described here.

This project has adopted the Microsoft Open Source Code of Conduct. For more information, see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

vscode-powershell's People

Contributors

andyleejordan avatar aspenforester avatar bergmeister avatar corbob avatar daviwil avatar dependabot-preview[bot] avatar dependabot[bot] avatar dfinke avatar fflaten avatar fullenw1 avatar github-actions[bot] avatar glennsarti avatar isidorn avatar janegilring avatar justingrote avatar kamilkosek avatar mad-mike avatar nohwnd avatar omniomi avatar pcgeek86 avatar powerschill avatar rjmholt avatar rkeithhill avatar seeminglyscience avatar sydneyhsmith avatar travisclagrone avatar travisez13 avatar tylerleonhardt avatar vmsilvamolina avatar xtqqczze avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vscode-powershell's Issues

Enable the use of WebSocket channel for PowerShell Editor Services

Adam Driscoll's new WebSocket channel in PowerShell Editor Services makes it possible to connect to a remote Editor Services host. We should figure out how to make it possible to connect to such a server via the VS Code extension (including having settings to configure the connection).

Implement new deactivate() method

With the December 2015 update of VS Code a new deactivate() method has been introduced to allow extension deactivation. This will allow us to shut down the language server when the extension needs to close, improving the experience around extension upgrades.

More info: microsoft/vscode#537

Create Yeoman generator for PowerShell projects

Visual Studio Code uses Yeoman for their "File -> New Project" experience, so we need to produce a Yeoman template that can generate a new PowerShell module project. Potentially other project types as well (DSC resource, etc?).

How to suppress analysis warnings?

Some analysis warnings are really annoying. Can I suppress the warnings?
For example, it there's a issue about the Function Name, it will put a green line under all the content in that function.

missed something ? no intellisense for built-in cmdlet

jsut installed vs code + powershell extension and restarted vs code.
Now create a new .ps1 file, typing get- then [ctr]>+[space] I'm getting No suggestion message.
Go to definition don't seems to work either...
Any thoughts ?

PowerShell Local Configuration Manager Autocomplete adds extra characters

When writing LCM configuration with Code I found that it adds an extra character at the beginning of the code when using the intelisense. Example seen below, if you use intelisense to autocomplete the settings of the LCM it leaves the first character you typed to search for completion.

[DscLocalConfigurationManager()]
Configuration LCMPull {
    Node Localhost {
        Settings {
            aActionAfterReboot = 'ContinueConfiguration'


        }
    }
}

Intellisense Broken

With 2 fresh installations on 2 seperate Windows 7 installations, Intellisense appears to be broken, with no suggestions offered for Cmdlets or variable names.

Both were installed via the built in extension installer

Debugger is not writing script output to the Debug Console

When running the debugger, debug console output never appears. The DebugTest.ps1 script will run, variables can be watched, breakpoints work, etc - but no output will ever appear in the debug console. We've attempted multiple script and launch.json configurations with no success. The latest attempt was made with:

launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "PowerShell",
            "type": "PowerShell",
            "request": "launch",
            "program": "DebugTest.ps1"
        }
    ]
}

We've tried this on a couple different installs on two different machines.

DebugAdapter.txt
EditorServices.txt

Enumeration support

The whole enumeration / enum keyword feels like it's not implemented to have a support for it. Doesn't highlight the keyword or it's content and doesn't offer any snippets.

CPU Load hit 99% while vscode running

I think this is related to the powershell extension. I installed vs-code last week, and then late last week was an update. Today when I fired up vscode and started working I noticed the fan starting spinning up and stayed up.

powershell-editor-cpu-load

After I closed vscode down that went away. In defense of vscode here I only had 6 files open and only editing one, and honestly it was about an hour before I actually started editing a file, but I noticed the fan spin up before then. I thought perhaps I was getting an update via windows updates so I didn't think anything about it, until after a while I realized the fan never stopped.

Snippets discussion - bracing style

I (reluctantly) would like to open a discussion regarding which bracing style to use for snippets. Right now, the latest snippets file uses Allman style bracing e.g.:

function foo
{
    ...
}

But the bulk of the PowerShell code I've seen in the wild uses K&R style e.g.:

function foo {
    ...
}

I know there are details of bracing style the community at large doesn't agree upon like whether or not to use cuddled else but I do believe K&R is fairly well accepted at the "top level".

Would anyone object strenuously if I changed the snippets to use K&R?

Where-Object does not seem to highlight properly

when using code this like this

Get-Process | Where-Object -FilterScript {
    # do things
}

the Where-Object does not highlight properly. the 'Where' goes purple and the '-Object' goes white (default theme).
image

not a huge deal, just an FYI. Thanks!

Document settings

It would be nice to have a readme for all configurable settings related to PowerShell in VS Code, such as
"PowerShell.editorServicesHostPath"
"PowerShell.waitForDebugger"
"PowerShell.enableLogging"

"Run Selected" Fails to Execute in v0.2.0

Side-loaded the v0.2.0 release for testing and experimentation today. Have noticed that the F8 functionality ceases to work and the output window for PowerShell is unavailable.

Add warnings when PowerShell extension is used on Linux and Mac OS X

The language and debugging services are not supported on Linux and Mac OS X so a warning message should be displayed when the extension is activated on either of those platforms. Syntax highlighting and snippets support will still be available on those platforms, however.

Not getting features shown in article

I've upgraded to VS Code 0.10.1 and installed the extension per the instructions. Opening the examples folder as suggested. Right-clicking on the "Do-Work 5000" entry (as shown in the gif) in the DebugTest.ps1 file only shows the following choices in the pop-up window: Change All Occurrences | Copy | Cut | Paste

A couple of restarts and still no luck. Thoughts?

Extension loads but doesn't work when Code is loaded from a command line.

I open powershell command console and type Code then hit enter (also tried with Code . ) and the extension doesn't work. if I use the Code shortcut from my task bar it works fine. Though doing ">ext show" says the extension is loaded, it's not working. I type "get-pro" and ctrl+space and I get completion items in the taskbar launched code, but not in the powershell command line launched code.

Configuration type not recognized in launch.json

I used the launch.json sample from c:\Users\<yourusername>\.vscode\extensions\daviwil.PowerShell\examples:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "PowerShell",
            "type": "PowerShell",
            "program": "DebugTest.ps1"
        }
    ] 
}

For type Visual Studio Code shows a warning: Value is not an accepted value. Valid values: ["node"].

There is also another warning Missing property "request" in launch.json

64-bit PowerShell modules are not being loaded

From microsoft/vscode#714
From @MakwaWes
CC @daviwil

Hi,

Problem
Some PowerShell modules aren't automatically loaded by 'Microsoft.PowerShell.EditorServices.Host.exe'.
The following path isn't included : '**C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules**'
although it actually reads the x64 counterpart ('C:\Windows\SysWOW64\WindowsPowerShell\v1.0\Modules').

Thanks !

Remote language and debugging experience from non-Windows OS

Scenario

I'm using a Macbook Pro, running Mac OS X El Capitan 10.11.1. I'm authoring PowerShell scripts in Visual Studio Code, but for obvious reasons, I don't have Intellisense capabilities, or line-by-line debugging support.

Proposed Solutions

A couple of potential options for solving this scenario are:

  1. Add support for PowerShell to execute natively on non-Windows operating systems (Mac OS X)
  2. Support remote debugging through PowerShell Remoting (PSSession) / Windows Remote Management (WinRM), via the Visual Studio Code Debug Adapter.

Cheers,
Trevor Sullivan
Microsoft MVP: PowerShell
http://trevorsullivan.net
http://twitter.com/pcgeek86

/cc @daviwil

Package Latest Release for Side-Loading

Is there any intention to package 3.1 as a .zip release for sideloading? My work environment is disconnected - without a way to mirror the packages for sideloading, I can't distribute to my team. I would vastly prefer to grab the package from here for this purpose.

Signature help does not appear in VS Code 0.10.0

Not sure yet whether this is a configuration issue or something else. I don't see the signature help request get called at all, so maybe something changed after 0.9.2 where it isn't getting triggered the same way anymore.

Snippets discussion - productivity feature or teaching feature

I guess I've gotten used to C# snippets that are "functional/productive". I find snippets like this in the PowerShell extension to be an awkward hybrid:

switch ($x)
{
    'value1' {  }
    {$_ -in 'A','B','C'} {}
    'value3' {}
    Default {}
}

Seriously, what are the odds that I'll have value1 as a case or a second or third case as shown above. I believe these were written to show how to use a feature i.e. they are teaching. That is admirable but as soon as the user learns the features of switch, this snippet becomes cumbersome because now it is a toss-up WRT how much code they have to "delete" to make the snippet conform to their intent versus how much they would have typed in the first place without using the snippet.

I propose that at the very least the "common" language features lean more towards being productivity snippets and not "teaching" snippets. I recommend changing the switch statement snippet to something like:

switch ($variable) {
    condition { action; break }
    Default {}
}

Where the cursor is put on a condtion placeholder second after $variable and then the action placeholder would be third.

BTW here are a few more examples of what I'm talking about:

try
{
    1/0
}
catch [DivideByZeroException]
{
    Write-Host "Divide by zero exception"
}
catch [System.Net.WebException],[System.Exception]
{
    Write-Host "Other exception"
}
finally
{
    Write-Host "cleaning up ..."
}

for ($i = 1; $i -lt 99; $i++)
{

}

Everybody who uses the try/catch/finally snippet is going to have to remove the DivideByZeroException and likely have to change the last catch to use an exception they want to catch (or not specify one at all). I believe there should a single exception there and it should be a placeholder. Likewise everybody is going to have to replace 99 in the for snippet. Might as well make it a placeholder.

args not passed to script being debugged from launch.json

I have tried several combinations of "args": [] and none of them produce a $args in the debugger. Should the "args" parameter for a configuration work? Looking through the source but not finding anything yet.
{
"version": "0.1.0",
"configurations": [
{
"name": "PowerShell",
"type": "PowerShell",
"program": "PowerShell Scripts/output.ps1",
"args": ["Verbose:$true"],
"request": "launch"
}
]
}

The debugger launches fine, but attempts using "-Verbose", "-Verbose:$true", or "/Verbose:$true" do not get passed to $args. The "output.ps1" file is very simple:

Write-Output $args
Get-Process
Write-Verbose -Message "Debugging PS in VSCode!"

Get-Credential cmdlet is not supported

For talking with Exchange Online I need to enter credentials.

My favorite way to get them is this:
$LiveCred = Get-Credential

But in VS Code on windows opens to let me enter them.

When a file is opened through WebDav the extension crashes

When a PowerShell File is opened through a WebDav Path (e.g SharePoint Library access through Windows Explorer) the extension crashes with the following error in the EditorServices.log:

FATAL UNHANDLED EXCEPTION:

System.UriFormatException: Invalid URI: The hostname could not be parsed.
   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
   at System.Uri..ctor(String uriString)
   at Microsoft.PowerShell.EditorServices.Workspace.ResolveFilePath(String filePath)
   at Microsoft.PowerShell.EditorServices.Workspace.GetFileBuffer(String filePath, String initialBuffer)
   at Microsoft.PowerShell.EditorServices.Host.LanguageServer.HandleDidOpenTextDocumentNotification(DidOpenTextDocumentNotification openParams, EditorSession editorSession, EventContext eventContext)
   at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher`1.<>c__DisplayClass4`1.<AddEventHandler>b__3(Message eventMessage, TSession session, MessageWriter messageWriter)
   at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher`1.<DispatchMessage>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.PowerShell.EditorServices.Host.LanguageServer.<ProcessMessage>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.PowerShell.EditorServices.Host.MessageLoop.<ListenForMessages>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.PowerShell.EditorServices.Host.MessageLoop.<StartMessageLoop>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Nito.AsyncEx.AsyncContext.<>c__DisplayClass3.<Run>b__1(Task t)
   at System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Nito.AsyncEx.AsyncContext.Run(Func`1 action)
   at Microsoft.PowerShell.EditorServices.Host.MessageLoop.Start()
   at Microsoft.PowerShell.EditorServices.Host.Program.Main(String[] args)

PowerShell extension cannot be upgraded cleanly

I had multiple windows open. The editor I updated the Powershell Extension in only had xml files loaded in the open window and the working files section. I had a second window open with a .bat file in the editor and an assortment of files in the working files section. A few being ps1 files. I am unsure if the Powershell editor services will still be loaded/locked if there are files in the working files section or not.

I updated the extension and it reloaded the current editor with the xml files. At this point the extension plugin stopped working and could no longer load extensions. I then relaunched the editor and I started getting errors where the extensions plugin was crashing. A second restart cleared this up, but the Powershell plugin was left in a broken state. What was left in the directory was the following:

.vsixmanifest
bin --> Microsoft.PowerShell.EditorServices.dll
--> Microsoft.PowerShell.EditorServices.Host.DebugAdapter.cmd
--> Microsoft.PowerShell.EditorServices.Host.exe
--> Microsoft.PowerShell.EditorServices.Protocol.dll

I am assuming the second open editor kept the Editor Services locked and broke the update. @daviwil we talked about the log maybe being the culprit, but I did not have the editor services log still loaded in cmtrace, so that was not what had the lock.

Should VS Code require a full restart before fully updating it's plugins instead of just the currently open editor? If we compare VSCode to Atom, I believe Atom requires a complete restart. When you use the Restart prompt presented by a extension install or update, it only restarts the current window and not all windows. I am unsure if this would be something this plugin should fix or VS Code itself.

I can try to find some more logs if you need, I didn't see any at first glance since I had restarted the editor so many times. I am also going to try to reproduce this in a few different ways later when i have more time.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.