
PowerShell 7.0 - omiossec
https://devblogs.microsoft.com/powershell/announcing-PowerShell-7-0/
======
Ididntdothis
I 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
I 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).

~~~
nunez
The start time is a major disadvantage behind Powershell. It takes 3 seconds
to load even if you disable profiles completely versus <1 second for Python,
Ruby or Bash.

~~~
JeffreySnover
Process creation on Windows has always been _significantly_ slower than Unix.
That is why PowerShell is skewed towards "built-ins" vs launched applications.
The ramification of that is slower startup times.

Interesting note - it is also the reason why PowerShell was able to adopt the
more natural Verb-Noun model for cmd naming. In Unix, this would produce a
huge # of files OR and you couldn't do "VERB NOUN" because then you would have
to multiplex on the VERB. Unix's "NOUN VERB" is the result.

BTW - VMS DCL stepped on all these rakes which is why it is have VERB/NOUN and
half NOUN/VERB. A complete mess.

Jeffrey Snover [MSFT]

~~~
animalnewbie
Would you consider a powershell server process to speed up startup?

~~~
SteveL-MSFT
This is an idea we've discussed, but not something we're investing in right
now. It could also solve the sudo/elevation problem for cmdlets. However a
privileged service would also bring more security concerns.

~~~
animalnewbie
Hey Steve you're doing a great job with PS! Thank you for all the hard work
you and your guys are doing. You are also exceptionally responsive on GitHub.

------
kbd
I'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.

~~~
dfxm12
Automation of tasks in Microsoft products in general, but particularly Office
365.

~~~
sbierwagen
Looking at it, seems like Microsoft mostly intended Powershell integration to
be used for admin/IT tasks, rather than end-user task automation.
[https://docs.microsoft.com/en-
us/office365/enterprise/powers...](https://docs.microsoft.com/en-
us/office365/enterprise/powershell/why-you-need-to-use-office-365-powershell)
Am I off base?

~~~
exyi
I guess you are right. End users should be clicking buttons :D

------
tony
Just look at that change log:
[https://github.com/PowerShell/PowerShell/blob/master/CHANGEL...](https://github.com/PowerShell/PowerShell/blob/master/CHANGELOG/7.0.md)

Meticulous. And clicking the headers link to comparisons at the tag level:
[https://github.com/PowerShell/PowerShell/compare/v7.0.0-prev...](https://github.com/PowerShell/PowerShell/compare/v7.0.0-preview.6...v7.0.0-rc.1)

And the hover link to the left of headers link perfectly to the section:
[https://github.com/PowerShell/PowerShell/blob/master/CHANGEL...](https://github.com/PowerShell/PowerShell/blob/master/CHANGELOG/7.0.md#700-rc1
---2019-12-16)

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
Yes, 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.

------
jlgaddis
If 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
Having 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.

------
badrabbit
Pretty 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.

------
whalesalad
I 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.

~~~
icegreentea2
It 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/)).

------
josteink
I’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
I 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.

~~~
AnIdiotOnTheNet
People too young to remember the anti-trust days will deny it, but there is no
good reason to trust that this isn't Microsoft's long term plan. You'd be a
fool to believe Microsoft has the best interests of the open source community
at heart.

~~~
JeffreySnover
Those youngings probably don't remember what the Germans and Japanese did in
the 40's either.

Or the good old day's when Ultrix ran like a racehorse on 4MB of ram (it did
BTW!).

We don't do our credibility any favor when we live in the past and don't
update our worldview based upon current facts.

Jeffrey Snover [MSFT]

~~~
AnIdiotOnTheNet
Current facts: Microsoft shoves ads into the start menu and file explorer,
collects a ton of telemetry, resets application associations during updates,
and does its best to hide the ability to setup a local-only account during
install in its pay-for operating system.

So forgive me if I'm cynical of your company's current PR efforts.

------
ripley12
I 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)

------
Swtrz
Ternary 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.

------
qf0
[https://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.

------
discreditable
Will this version of powershell ever be baked-in to Windows? My Windows 10
1909 install is currently 5.1.

~~~
jamesgeck0
Powershell 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-...](https://docs.microsoft.com/en-
us/powershell/scripting/whats-new/cmdlet-versions?view=powershell-7)

~~~
TheGoddessInari
They 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.

------
6d65
I 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.

------
eitland
I 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...)

------
bluedino
Coming 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

------
22c
Interestingly, 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.

------
fetbaffe
I 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-
exclu...](https://stackoverflow.com/questions/15294836/how-can-i-exclude-
multiple-folders-using-get-childitem-exclude)

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
>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)

~~~
nickcox
Not sure that's a fair comparison though. `du` isn't built in to bash, afaik;
you could just as easily type `du -sh <folder>` in PowerShell.

If you /did/ need to do it without `du` then it would be something like:

`dir <folder> -Recurse | measure -Property Length -Sum`

which is easier to remember than whatever the equivalent bash would be, imo.

~~~
JensRex
>Not sure that's a fair comparison though

Maybe not in a technical sense, but I've never encountered Bash without GNU
coreutils (or busybox). I'm just comparing how I would solve a problem in a
typical *nix environment, compared to a Windows environment.

------
jamesgeck0
Homebrew 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
3 hours later:

> Current version: 7.0.0

------
zeusly
Does anyone have a good resource / tutorial how to learn powershell as both a
scripting language and to be powerful in daily shell life?

~~~
LilBytes
I'd start here:

[https://www.manning.com/books/learn-windows-powershell-
in-a-...](https://www.manning.com/books/learn-windows-powershell-in-a-month-
of-lunches-second-edition)

------
seemslegit
Any chance that there exists an effort to maintain mirror forks of Microsoft
open-source projects with telemetry code entirely removed ?

~~~
JeffreySnover
There 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-p...](https://devblogs.microsoft.com/powershell/new-telemetry-in-
powershell-7-preview-3/)

Here is all the telemetry:
[https://aka.ms/psgithubbi](https://aka.ms/psgithubbi)

Jeffrey Snover [MSFT]

~~~
seemslegit
Thanks 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.

~~~
SteveL-MSFT
Given that PowerShell is Open Source, you can exactly see the telemetry code.
Before we added the first bit of telemetry or when we needed to add more, we
published RFCs for community feedback disclosing what we were collecting and
why. [https://github.com/PowerShell/PowerShell-
RFC/blob/master/5-F...](https://github.com/PowerShell/PowerShell-
RFC/blob/master/5-Final/RFC0016-Census-Telemetry.md) and
[https://github.com/PowerShell/PowerShell-
RFC/blob/master/2-D...](https://github.com/PowerShell/PowerShell-
RFC/blob/master/2-Draft-Accepted/RFC0036-AdditionalTelemetry.md). We recognize
that some users don't want to send any, which is why we made it simple to
disable (completely!). However, opt-in telemetry also means we would receive
very little making it not useful. Before any telemetry is added, we also go
through an extensive privacy review to ensure no personally identifiable
information is included (therefore all our telemetry is anonymous).

~~~
seemslegit
The average user cannot be assumed or expected to be following powershell
blogs or to have gone through the community discussions or to have read the
RFCs and definitely not to have individually reviewed the source code, they
would just download and run powershell while not being aware that this
functionality even exists and be dismayed once they learn about it. In this
onboarding scenario the current form does not even satisfy good faith
disclosure criteria much less can be said to constitute an informed consent.

A trustworthy way to do this would have been to have the user presented with a
prompt upon first interactive run explaining them the importance of the
telemetry to msft with a link to relevant documentation and privacy policy and
a Y/N selection, anytime the collection logic changes or a new datum is added
the consent needs to be renewed, and if it turns out that under those
conditions most users choose not to enable it than it will probably be the
single most actionable user input msft receives from/about its telemetry
practices.

------
fractal618
How does using powershell in Linux compare to bash? I imagine one has
strengths over the other

~~~
alkonaut
When 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.

------
redog
docker run –it mcr.microsoft.com/powershell:preview

