13 ms·
PowerShell 7.0
- 6d65 7y agoI like PowerShell in general. But it's very slow. Both the startup time and the responsiveness. Especially when having something like posh-git enabled. Having a Linux box with Alacritty and fish at home, makes it even more frustrating to start in on Windows and wait seconds to type. And unfortunately, PS 7.0 is not a lot faster, still noticeable lag in startup. The good part is .net integration, being able to use standard .net classes in scripts can be really helpful.
- bluedino 7y agoComing from a bash background, PowerShell is consistently annoying. Here's an example, passing an XML file to a cmdlet: Some-Command -Param1 -FileData .\foobar.xml Cannot process argument transformation on parameter 'FileData'. Cannot convert value ".\foo.xml" to type "System.Byte[]". Error: "Cannot convert value ".\foo.xml" to type "System.Byte". Error: "Input string was not in a correct format."" In bash you would just do: somecommand < foobar.xml Instead you have to create an object and, do a conversion: [Byte[]]$Data = Get-Content -Path ".\foobar.xml" -Encoding Byte -ReadCount 0 Then, run the same command using that object instead of the file: Some-Command -Param1 -FileData $Data
- Swtrz 7y agoTernary operators and better Get-Error output are very welcome additions, Ive been writing a few infrastructure testing tools in Pester that could possibly be consolidated.
- 22c 7y agoInterestingly, I saw that PowerShell 7.0 was the default level of documentation when I was browsing Microsoft docs yesterday and figured I must've missed the announcement. I like the pipeline parallelization feature, I wish more languages offered simple semantics like this to just parallelize some basic tasks.
- josteink 7y agoI’m not a PowerShell fan by large, but you can tell a whole lot of effort went into this. And for what ends? Seemingly to make more Microsoft technologies and APIs available on non-Windows platforms. I genuinely like this part of the “new” Microsoft.
- ASalazarMX 7y agoI feel like we're in the "extend" phase of embrace-extend-extinguish cycle. The last step would be creating Microsoft Linux for Developers when enough market penetration has been achieved, and making sure their tooling is hard to maintain in other distributions.
- jamesgeck0 7y agoembrace-extend-extinguish refers to Microsoft's adoption of existing technology. It's not a great fit here; Powershell is their own thing.
- ASalazarMX 7y agoThis is just speculation on my part, but the technology being adopted is likely Linux. First Microsoft declares its war on Linux over (Microsoft loves Linux), then the Windows tooling is extended into Linux so the lines blur, then WSL was made so you don't have to leave Windows to use Linux tooling. In my paranoid scenario, a happy ending (for Microsoft) would be: the release of its own Linux that "just works" with the mixed tooling, and young developers considering pure Linux just for small projects.
- unreal37 7y agoAmazon has it's own Linux. Why not Microsoft?
- Ididntdothis 7y agoI think today embrace, extend and extinguish applies more to cloud providers like AWS. They take a lot of open source, wrap it into their own code and then lock people in. MS is one of the perpetrators but Amazon and Google are no better.
- kbd 7y agoI'm interested now that PowerShell is cross platform. For someone reasonably fluent in bash/zsh (and Python, etc.) already, could someone give examples of where they might use PowerShell? http://nushell.sh/ http://nushell.sh/ is an example of a new (non-POSIX) shell that's trying to be more structured, similar to PowerShell. Thanks to nu's new -c option, it's possible to use nu profitably even if you don't make it your shell. I doubt I'd ever use PowerShell as my system shell on Mac/Linux, but I don't want to close myself off from tools that might be useful for particular tasks or scripts.
- JdeBP 7y ago* https://github.com/jdebp/terminal-tests/blob/master/PowerShell/ColourMatrix.ps1 https://github.com/jdebp/terminal-tests/blob/master/PowerShe... You've probably seem the widely circulated terminal colour test scripts written for Unices and Linux-based operating systems, such as 256colors.pl written in Perl and distributed with XTerm. This is a PowerShell approach. I wrote it to test what Windows Terminal could do. It exemplifies several things. It exemplifies the rapid prototyping nature of PowerShell. Development of this script went through several (unpublished) iterations, much of which was tested interactively. Doing that with Edit-Compile-Debug in, say, C would have taken longer. It exemplifies that PowerShell is not limited to either TUI or GUI. The script both writes stuff to a Windows console and displays a GUI window with buttons. It exemplifies the runtime library that one gets with PowerShell; here using Forms classes, the String class (including .NET string formatting), and of course the Console class. One gets the .NET (Core) Framework, basically, with which (on Windows) one can do things as varied as rewrite XML files, execute SQL, and (using its .NET API) enqueue builds on a TFS server. In a very trivial way, it even exemplifies script blocks as lambdas (in the {Click} blocks being passed to the event handler registrations). There's a whole lot more that it does not exemplify of course; including stuff like the -f and -is operators, hashes and arrays, PSCustomObjects, the object pipeline, ForEach-Object and Where-Object, nullable variables, and the extra standard streams. And it really only tangentially, with the test at the top, illustrates how PowerShell is akin to TCL, LUA, et al., in that it can be (and is) embedded with different front-ends. In this case, the test ensures that the script isn't accidentally run in PowerShell ISE, which isn't a useful place to run the script, but more importantly which handles its console I/O really slowly to the point that it's actually difficult to interact with the UI. (I didn't employ a similar check for Visual Studio, whose embedded PowerShell has a console UI that is zero rows high.)
- discreditable 7y agoWill this version of powershell ever be baked-in to Windows? My Windows 10 1909 install is currently 5.1.
- jamesgeck0 7y agoPowershell Core 6.0 wasn't fully backwards compatible. I imagine that full backwards compatibility would be a requirement to replace 5.1. It looks like Powershell 7 still can't run some 5.1 scripts. Here's a compatibility table: https://docs.microsoft.com/en-us/powershell/scripting/whats-new/cmdlet-versions?view=powershell-7 https://docs.microsoft.com/en-us/powershell/scripting/whats-...
- TheGoddessInari 7y agoThey changed the default path outout of applets like get-childitem. Microsoft employees stated that this would break many older scripts, but it wasn't listed as a breaking change. It's unlikely to ever reach even generally acceptable levels of compatibility with the built-in version.
- iamaelephant 7y agoThere's no reason to bake tools like this into an OS or tie them to OS versions. Download the tools you need. If you need to "bake" them anywhere, bake them into your containers.
- int_19h 7y agoThe reason is to have a standard shell that is there on every OS. Not everything is servers and containers.
- iamaelephant 7y agoHow many non-server machines do you find yourself regularly needing a shell on where downloading it isn't an option? Why does it need to be pre-installed?
- whalesalad 7y agoI hope that Microsoft has a long-term plan for Powershell. It started as a simple shell and has evolved into an almost full-fledged programming language.
- FirstLvR 7y agowell, it is is incredible useful with dynamics 365
- nunez 7y agoThey do. Many of their enterprise offerings (Exchange, Office 365, Active Directory) and Azure services are Powershell-first now
- icegreentea2 7y agoIt was (almost? I never played with PS1.0) always a "almost full-fledged programming language". It's been a CLR front-end for forever. All the way back to PS2.0 you could (if you wish) define and execute an entire WPF GUI in Powershell (see https://poshgui.com/ https://poshgui.com/).
- jamesgeck0 7y agoHomebrew is the recommended way to install on macOS, but the cask is currently still on 6.2.4. https://formulae.brew.sh/cask/powershell https://formulae.brew.sh/cask/powershell
- oldgradstudent 7y ago3 hours later: > Current version: 7.0.0
- jlgaddis 7y agoIf you want to avoid the telemetry, make sure to set the appropriate environment variable (to anything) before running PowerShell for the first time! On Linux, for example, you'll want to add something like this to your initialization / startup files: export POWERSHELL_TELEMETRY_OPTOUT=1 (Even then, I'm not sure that works for the "AppInsights" stuff!)
- ta8285738 7y agoHaving to opt-out of telemetry in your shell is revolting. I wasn't even aware it was there. They really need better up-front warnings (or opt-in) for their OS and shell etc. Another nail in the coffin, horrible dark pattern.
- Ididntdothis 7y agoI was forced to use Powershell for a project so after years of ignoring I finally learned it. It’s actually not that bad and I have even done some stuff on my Mac with Powershell core. I just wish they made the language nicer and more consistent. There are so many weird quirks around functions, modules, scope and classes that make life pretty difficult in larger code bases. I would love to see something closer to C# (or even TypeScript) that still can use cmdlets easily. The current Powershell language to me feels like a weird hack but not something well designed. Typescript and C# have demonstrated that MS can design good languages. This leads me to another complaint. MS is cranking out a lot of useful cmdlets that would also be useful for C# programmers but using them from C# is quite painful.
- animalnewbie 7y agoI have to say some of the things that I assumed were quirks turn out to be well engineered decisions once I learnt powershell in full. For example I started appreciating the way output in PS1 works only after using the parallel for each and was floored by how everything fell in place. Take this from a full time Linux user, if you're not using powershell you're using an inferior shell. One major downside for cli warriors though- it takes a couple of seconds to start. (at least 6, I don't knoe about 7).
- vips7L 7y agoWith modules my pwsh 6 usually starts between 700ms - 2s. Not a big deal to me though.
- animalnewbie 7y agoCold start? My cold start is 20 seconds but after that about the same as you so I did a rough "average" to try to convey that :)
- vips7L 7y agoYes that is cold start. I wonder where your slow down is. I only use 2 modules and have a rather small profile to load though.
- ripley12 7y agoI was just trying to get a release candidate of PowerShell 7 working on macOS and Windows yesterday. It was a frustrating experience, because many essential keybindings are broken out of the box on macOS (Terminal.app, iTerm2) and Windows (using the new Windows Terminal). For example: ctrl-space is the usual shortcut to trigger menu completion, doesn't work. It's not difficult to make custom keybindings once you figure this out, but many people's first encounter with PowerShell is going to be missing some critical UX features. Not a great situation. https://github.com/PowerShell/PSReadLine/issues/639 https://github.com/PowerShell/PSReadLine/issues/639 https://github.com/microsoft/terminal/issues/879 https://github.com/microsoft/terminal/issues/879
- eitland 7y agoI used Powershell a lot last year and it is really amazing to be able to script things like Azure Information Protection and use Azure Application Insights for logging..! (Of course, Microsoft being Microsoft one still needed to install MS Office on the server to use Azure Information Protection on a pdf or even a txt file...)
- fractal618 7y agoHow does using powershell in Linux compare to bash? I imagine one has strengths over the other
- alkonaut 7y agoWhen you are doing things that operate on unstructured text and files you will probably get a more concise script with bash most of the time. As soon as you do anything beyond that with structured data or complex processing (e.g you fetch a Json from a web api, filter some properties in it with a regex, save the result as xml, send the xml to a program, parse the output using some complex logic,...) then the powershell is way more powerful. You might say it’s more a tool that shines in the cases where you’d already give up on bash and use python or something else instead, because you need some libraries, some structured error handling etc.
- fetbaffe 7y agoI use Powershell daily on novice level (shell only, no scripts). There are some nice things compared to bash, like tab completion on program arguments. However it is somewhat slow. What surprises me is that somethings are just awkward & cumbersome, like excluding multiple folders when doing Get-ChildItem. https://stackoverflow.com/questions/15294836/how-can-i-exclude-multiple-folders-using-get-childitem-exclude https://stackoverflow.com/questions/15294836/how-can-i-exclu... Or escaping arguments with correct quoting. Sometimes I can't get it to work, like searching for strings with weird characters, especially if I need to combine it with git grep.
- JensRex 7y ago>tab completion on program arguments Bash has that as well. This thread is full of praise for PowerShell, but every time I've tried to use it, I've become annoyed with it. For example, to get the size of a folder in Bash, I'd type `du -sh <folder>`. In PowerShell it's some absurd code spaghetti that someone put in a Github repo [1]. No matter what I try to do in PS, I find the syntax ridiculously verbose. Maybe I just don't get it, whatever it is. \shrug\ [1] https://github.com/gngrninja/PSFolderSize https://github.com/gngrninja/PSFolderSize
- flukus 7y agoThis is my experience too, anything non-trivial quickly becomes an absolute mess, even the trivial things often have bad defaults. A few years ago I looked into using it as a build system for .net projects but ended up tearing my hair out on even the simplest things like removing directories or recursively copying html files: http://flukus.github.io/powershell-is-a-joke.html http://flukus.github.io/powershell-is-a-joke.html
- CuriousSkeptic 7y agoIf you do find yourself in this spot. Have a look at Invoke-Build. It adds some sanity to such scripts, to the point of almost being enjoyable. Edit: (I only use it to orchestrate and combine other build systems though)
- 7y ago
- qf0 7y agohttps://www.youtube.com/watch?v=2gJgL8a0YGA https://www.youtube.com/watch?v=2gJgL8a0YGA talk a Microsoft developer in the PowerShell team, did a month or two ago at a hedge fund called Jane Street. Talking about new changes in PowerShell 7.0 etc.
- zeusly 7y agoDoes anyone have a good resource / tutorial how to learn powershell as both a scripting language and to be powerful in daily shell life?
- LilBytes 7y agoI'd start here: https://www.manning.com/books/learn-windows-powershell-in-a-month-of-lunches-second-edition https://www.manning.com/books/learn-windows-powershell-in-a-...
- redog 7y agodocker run –it mcr.microsoft.com/powershell:preview
- seemslegit 7y agoAny chance that there exists an effort to maintain mirror forks of Microsoft open-source projects with telemetry code entirely removed ?
- solarkraft 7y agoThere is VSCodium, I'm not aware of others.
- seemslegit 7y agoThanks ! Was not aware of VSCodium
- seemslegit 7y agoAlthough it appears to be a binary-only download claiming to be free of telemetry and non-floss code, it does not share the fork itself, what am I missing here ? EDIT: "This is not a fork. This is a repository of scripts to automatically build Microsoft's vscode repository into freely-licensed binaries with a community-driven default configuration."
- JeffreySnover 7y agoThere are enough examples of companies doing terrible stuff that concerns are entirely understandable. Let me take the opportunity to say: 1) YOU ARE NOT OUR PRODUCT! 2) Our goal is to use telemetry to help us make better decisions about what will help our customers (as with with projects, only a subset of users are active in our community feedback process) 3) We are super open about the telemetry (including going through the PowerShell community review process) and publish all the data. More details here: https://devblogs.microsoft.com/powershell/new-telemetry-in-powershell-7-preview-3/ https://devblogs.microsoft.com/powershell/new-telemetry-in-p... Here is all the telemetry: https://aka.ms/psgithubbi https://aka.ms/psgithubbi Jeffrey Snover [MSFT]
- seemslegit 7y agoThanks for taking the time to address this (And a great thanks for Powershell ! Which regardless of some reservations about its language is a great technology and a major leap forward in terms of soundness and productivity in the IT sphere) I fully appreciate the importance of telemetry, crash reports etc. for product owners and teams, and am not under the impression that it is currently being abused by msft. However, as telemetry is a very general functionality and by their nature both company policies and software products are subject to frequent changes and given the many example of abuse by some companies quite comparable to msft in terms of their scope of impact and business incentives I don't think its usefulness overrides the principal concerns regarding the practice of including it enabled by default with distributed products even when disclosed. Anything that does not require an explicit user action to enable telemetry imo falls short of the desired ethical standard of respect for user agency that should exist in an ecosystem that wishes to foster trust between vendors and users and this goes double for open-source projects.
- tony 7y agoJust look at that change log: https://github.com/PowerShell/PowerShell/blob/master/CHANGELOG/7.0.md https://github.com/PowerShell/PowerShell/blob/master/CHANGEL... Meticulous. And clicking the headers link to comparisons at the tag level: https://github.com/PowerShell/PowerShell/compare/v7.0.0-preview.6...v7.0.0-rc.1 https://github.com/PowerShell/PowerShell/compare/v7.0.0-prev... And the hover link to the left of headers link perfectly to the section: https://github.com/PowerShell/PowerShell/blob/master/CHANGELOG/7.0.md#700-rc1---2019-12-16 https://github.com/PowerShell/PowerShell/blob/master/CHANGEL... Sections: Breaking Changes, Engine Updates and Fixes, General Cmdlet Updates and Fixes, Code Cleanup, Tools, Tests, Build and Packaging Improvements, Documentation and Help Content That's better than what I see in node and python projects. So much thought and caring. Let's try it: > brew cask install powershell Updating Homebrew... ==> Auto-updated Homebrew! Updated 2 taps (homebrew/cask and caskroom/cask). ==> Updated Casks caskroom/cask/microsoft-edge homebrew/cask/microsoft-edge ==> Downloading ... powershell was successfully installed! ~ 23s > pwsh PowerShell 7.0.0 Copyright (c) Microsoft Corporation. All rights reserved. https://aka.ms/powershell Type 'help' to get help. PS /Users/tony> I'm using Powershell, a C# application, on MacOS, in iTerm2. I'm fine with it. Also, the subsequent bootup of pwsh was faster than the first. Edit: You can open vim from it. Somehow, it's even detecting my tmuxp (which is in ~/.local/bin). I'm guessing it inherits PATH's from the parent shell?
- SteveL-MSFT 7y agoYes, pwsh inherits from parent. However, we've made improvements to use PS7 as a login shell. When used as a login shell, we exec sh on Linux and zsh on macOS to setup the environment, then exec pwsh to inherit.
- badrabbit 7y agoPretty exciting, someone showed me a while back how powershell 6 has a wget command. I look forward to simple things like this But man,powershell is lightyears ahead of any *nix alternative. In particular, JEA for security and invoke-command (imagine running a block of code in parallel on multiple machines and get results locally) and other common cmdlets like import-csv where on something like bash you do have the capacity to do write a function that does these things but powershell provides these using a consistent interface,much like stdlibs do in application programming languages. After using powershell,using bash felt like trying to use C without it's stdlib. I think it's just windows' way of making up for nor having the equivalent of GNU userland tools like awk,sed and grep.