News for hackers. Stuff that matters.
Re:Rumors of Cmd’s death have been greatly exaggerated by majkinetor on Thursday January 05, 2017 @12:10AM (#13324921)
Powershell should have been set as default years ago, particularly on core.

It escapes me how windows admin community still largely ignores Powershell while clicking next in the loop.

Until MS makes Windows Powershell first, adoption will change very slowly as we witnessed so far. Nano server will hopefully bring it faster.

Its a terrible injustice as posh is best shell in the existence IMO.

What I really want to see in future is exporting entire control pannel config as posh script. This is the perfect time to digg into it given that control panel is being transformed into 'settings'.

Re:Rumors of Cmd’s death have been greatly exaggerated by random_upvoter on Thursday January 05, 2017 @07:32AM (#13326600)
Many people are put off by Powershell because they believe that 20 years of experience in bash or CMD will allow them just fire up Powershell and get by. You will not get by. There's a good amount of gotchas and you will get stuck on some unexpected behavior within minutes.

The thing is, if you want to use Powershell you do need to spend a few days just learning Powershell and nothing else. I have the impression some people don't want to do the effort. It's a pity because it truly is vastly better than any other shell in existence.

Re:Rumors of Cmd’s death have been greatly exaggerated by pshposh on Thursday January 05, 2017 @01:38AM (#13325223)
PowerShell is almost like using the python interactive interpreter as your command line but better. I was convinced how cool it was when I could import a C# .dll and load the types into PowerShell. You can even just write C# 'inline' and it compiles it on the fly.

It baffles me as well how many Windows people I work with ignore it almost.

Re:Rumors of Cmd’s death have been greatly exaggerated by NoGravitas on Thursday January 05, 2017 @08:35AM (#13326970)
This is really the best analogy to explain PowerShell to Unix people. PowerShell's sweet spot is really not interactive use, but sysadmin-type scripting. It's very much like using Python for sysadmin tasks.
Re:Rumors of Cmd’s death have been greatly exaggerated by Too on Thursday January 05, 2017 @12:56PM (#13329504)
So essentially it's a programming language? For "scripting", why would I use it over just plain c#?
Re:Rumors of Cmd’s death have been greatly exaggerated by WorldMaker on Thursday January 05, 2017 @05:40PM (#13332123)
It's about like asking why would you use F# or (Iron)Python over C#? Different syntaxes have different strengths/weaknesses and the trade-offs can target different use cases and needs. At the end of the day it's whatever makes you (feel) productive.

In terms of specifics, PowerShell's strengths over C# for scripting are particularly in PowerShell's the ability to succinctly navigate hierarchies (folders, but also other folder-like trees) in a way reminiscent of shells from time immemorial, as well as to easily interleave native binary calls (and pipes/redirects/captures).

Some of it is the difference between grabbing C# binding for libgit off NuGet, LINQing my way through a the git DAG for the information I need versus running `git show xyz` or `git describe` directly in a shell and capturing that into a variable or piping that to whatever my next steps are. Depending on my level of abstraction and how often that script is called and if I'm paid to write that script or it is getting in the way of what I'm actually trying to work on, I use a different tool for the job.

Re:Rumors of Cmd’s death have been greatly exaggerated by paulmooreparks on Thursday January 05, 2017 @03:27PM (#13331044)
Because C# is designed around application development, whereas the PowerShell scripting language is designed around scripting and its peculiarities.
Re:Rumors of Cmd’s death have been greatly exaggerated by swah on Thursday January 05, 2017 @02:13PM (#13330363)
For starters, I would look into it if it had a different look like ConEmu (fonts, themes, fullscreen)
Re:Rumors of Cmd’s death have been greatly exaggerated by xemoka on Thursday January 05, 2017 @04:17PM (#13331480)
It does? You can run powershell in ConEmu—I run it in cmder.
Re:Rumors of Cmd’s death have been greatly exaggerated by int_handler on Thursday January 05, 2017 @01:41AM (#13325230)
Except Powershell isn't a real shell in the same way that cmd or any of the POSIX shells are. It's a REPL for a language running on the .NET VM. I'm neither a fan of the language nor having to wait several seconds due to the latency of having to start the .NET VM when you start posh.
Re:Rumors of Cmd’s death have been greatly exaggerated by ygra on Thursday January 05, 2017 @01:57AM (#13325296)
What is a shell for you then? If the defining characteristic is that it's not written in a managed language, well, okay, but I don't think many people share that sentiment.

I have observed the several seconds startup time last with PowerShell v2 or so and that was not the time needed for the CLR to start, but rather PowerShell which was slow to start. v5.1 starts instantly here and the only slow thing about it is my profile, which admittedly does a bunch of things that take time (it's not yet at a point where it's annoying me so much that I edit it, and I can start typing commands during that time anyway (considering that I often spend more time thinking about what to write that's okay)).

Re:Rumors of Cmd’s death have been greatly exaggerated by flukus on Thursday January 05, 2017 @02:06AM (#13325325)
> What is a shell for you then?

A way to execute programs. The parent is right, powershell is more like a REPL to execute .net code. It's still no where near as good as a unix environment.

Re:Rumors of Cmd’s death have been greatly exaggerated by ygra on Thursday January 05, 2017 @03:04AM (#13325545)
But as long as you only execute programs a script for cmd, bash, PowerShell and a number of other shells looks pretty much the same. In PowerShell executing a program is simply to state the program name (barring spaces in the path for now). You don't have to do something like execute_program(name, args, input_redirection, output_redirection, ...). Well, you can, if you're so inclined, but it's usually unnecessary. Any shell is "just a REPL for a scripting language". Interactive use is one of the tenets of a shell, otherwise it's more a batch processing system, I guess. And just like in other shells the language is one geared towards running commands (cmdlets or external), managing their execution and processing their output. That it works better for general programming than many other shell languages (in my eyes) is a nice bonus.

Heck, running programs is even easier than in most other shells since there's a specific token that stops argument parsing completely which means you don't have to care about quoting at all (an ever-present nightmare at times).

Re:Rumors of Cmd’s death have been greatly exaggerated by flukus on Thursday January 05, 2017 @05:58AM (#13326196)
The difference is that windows/PowerShell don't provide the programs that make a she'll useful.
Re:Rumors of Cmd’s death have been greatly exaggerated by ygra on Thursday January 05, 2017 @06:04AM (#13326222)
Wow, then I've done a lot of apparently-useless PowerShell work.

I beg to differ, by the way. Different is not the same as »not useful«. It's not a traditional Unix shell and doesn't pretend or want to be. That doesn't make it useless, just different.

Re:Rumors of Cmd’s death have been greatly exaggerated by tremon on Thursday January 05, 2017 @08:13AM (#13326819)
It's not a traditional Unix shell and doesn't pretend or want to be.

Except in the sense that it provides aliases for most popular Unix shell commands. They even made their aliases incompatible with other Unices, like every other traditional Unix shell.

Re:Rumors of Cmd’s death have been greatly exaggerated by loopykidney on Thursday January 05, 2017 @09:58AM (#13327534)
I agree that powershell is far from useless, but it does feel like there are a lot of cmdlets missing out of the box. It's real easy to end up in Get-WmiObject land for everyday admin tasks.
Re:Rumors of Cmd’s death have been greatly exaggerated by ygra on Thursday January 05, 2017 @10:41AM (#13327953)
But WMI is really, really huge. I can understand that there is a bit resistance to providing cmdlet wrappers around every single WMI class, although I think on Windows Server there are a lot more things exposed by default (and I think even more in modules that are not loaded by default).

Also, since PowerShell can work with WMI objects natively it's already close to what a cmdlet can provide.

Re:Rumors of Cmd’s death have been greatly exaggerated by vishbar on Thursday January 05, 2017 @06:00AM (#13326201)
Doesn't Bash (or any Unix shell) fail to fit your definition, then? Bash contains an interpreter for a language that, while lightweight, is still a separate interpreted language. In particular commands like cd can't be executed as separate programs.
Re:Rumors of Cmd’s death have been greatly exaggerated by useerup on Thursday January 05, 2017 @04:05AM (#13325790)
A shell is so named because it was envisioned as a way to interact with the operating system core (not kernel, the core typically consists of both kernel and userland processes/tools). Core and shell, get it?

A command shell is a shell that uses commands to interact with the operating system, whereas a GUI shell is a shell that uses a graphical user interface to let the user interact with the operating system core (services/tools/processes).

In Unix philosophy, a 'command' is almost synonymous with a 'program', except when it's not. Seems to me that you are stuck in the Unix mindset and refuse to entertain the idea that a "command" could be anything but a program. In fact, the Unix shell commands are already a hybrid concept: Commands can be magical built-in commands (like 'cd'), programs (like 'ls') or script files which will execute in a special surrogate process (a seperate shell process).

However, there is a problem with programs as commands: They are opaque. And because every program is started within it's own process, they are also limited when it comes to extending the shell features. This is why 'cd' is a special command that is not a program.

PowerShell is a fresh take on this: PowerShell commands are still used to interact with the operating system, but they need not be full-blown programs executing in their own process. Hence, PowerShell is in some ways even terser than the traditional sh shells. An example of this is the way that 'cd' is not a magic built-in command. In PowerShell 'Set-Location' (the command for which 'cd' is an alias) is implemented like any other command and packaged in module. Only this module is always distributed with PowerShell.

This approach also has several other advantages (not limited to):

* PowerShell "discovers" the parameters, types, positions of command parameters. It is the shell that performs parameter parsing, position matching and (most importantly) coerces values, e.g. parsing a string as a number when the parameter expects a number. This leads to much higher consistency.

* The shell can generate documentation from the command definition. Not possible with sh shells where you need authored documentation, because the parameter parsing is really the responsibility of each command.

* The shell can generate tab-completion and auto suggestions from the command. Not possible on sh shells where you need authored completion files to support completion. In PowerShell you get documentation and tab-completion even for scripts you write yourself!

* The commands may interact with the shell itself. This is important not just because you can implement commands like 'cd', but because the "shell" may actually be part of an application. A GUI administration tool can actually act as a shell, and commands can control the GUI. A very generic example of this is PowerShell ISE, where commands can actually open new windows/panes, change menus etc.

> The parent is right, powershell is more like a REPL to execute .net code.

Wrong. PowerShell is a REPL (i.e. a command shell) to execute PowerShell commands. PowerShell commands may be cmdlets but may also be programs. PowerShell may be implemented in .NET, but PowerShell scripts are not .NET code.

Re:Rumors of Cmd’s death have been greatly exaggerated by flukus on Thursday January 05, 2017 @06:01AM (#13326208)
Yes, I'm aware of all the selling points. They even sound great in theory. In practice though, PowerShell is nowhere near as easy as a UNIX environment.
Re:Rumors of Cmd’s death have been greatly exaggerated by pjmlp on Thursday January 05, 2017 @02:50AM (#13325489)
Says the one that never used a Xerox PARC like OS in anger.

A GUI workstation using a REPL for scripting/automatic is so much powerful than a plain UNIX shell.

Re:Rumors of Cmd’s death have been greatly exaggerated by raverbashing on Thursday January 05, 2017 @05:17AM (#13326046)
Type program.exe in powershell, it runs

Fits the definition for me

Re:Rumors of Cmd’s death have been greatly exaggerated by majkinetor on Saturday January 14, 2017 @04:08PM (#13400558)
With nano server speed is optimised. It starts under 500ms. It has too, otherwise it would be slower then docker run.
Re:Rumors of Cmd’s death have been greatly exaggerated by rikkus on Thursday January 05, 2017 @10:34AM (#13327893)
It's around 1.5 seconds here on an i7-6600U (whether I launch it in its own window or in a cmd window). I'd rather it was 1/10th of that as a maximum, but it's worth the wait!
Re:Rumors of Cmd’s death have been greatly exaggerated by josephcooney on Thursday January 05, 2017 @12:59AM (#13325087)
The horrible syntax of Powershell isn't something I can look past.
Re:Rumors of Cmd’s death have been greatly exaggerated by alkonaut on Thursday January 05, 2017 @06:01AM (#13326207)
I think it's fairly neat (I mean - for shell scripting not for interactive use). The problem with shells is that they want to do both. The alias system in PS tries to make it possible to use a more bash-like syntax in interactive and the verbose syntax in scripts, which is a good idea, but it's hard to get right.
Re:Rumors of Cmd’s death have been greatly exaggerated by ygra on Thursday January 05, 2017 @06:12AM (#13326256)
As someone who golfs in PowerShell and very frequently uses it interactively too, I think the complaints about lack of terseness are quite overblown. Aliases, parameter binding by position or pipeline, the ability to shorten parameter names as long as they remain unambiguous, parameter aliases – all features that are most important for interactive use. Apart from a few nagging things where parameter prefixes clash (gci -f matches Force and Filter) I think it's quite good. Besides, I gladly pay that little price for much improved readability, discoverability and memorability. No more pondering whether the -Recurse flag is -r or -R in this particular command, for example.
Re:Rumors of Cmd’s death have been greatly exaggerated by noinsight on Thursday January 05, 2017 @08:53AM (#13327069)
Also, since PowerShell is able to tab-complete cmdlets, parameters, parameter values (when they're enumerable) and even object properties, you hardly have to type much most of the time.

The only problem with the tab-completing is that since everything has a standard verb prefix, you always have to type the beginning of the cmdlet name.

Re:Rumors of Cmd’s death have been greatly exaggerated by freehunter on Thursday January 05, 2017 @08:46AM (#13327031)
I haven't used Powershell since Windows 7, but at least back then it was super slow to start. cmd.exe opens immediately, like a normal terminal emulator. Powershell took several seconds to open.

At least for me, if I'm opening the command line it's to get something done quicker and easier than I could with the GUI. Powershell wasn't that, at least on Windows 7.

Re:Rumors of Cmd’s death have been greatly exaggerated by greggyb on Thursday January 05, 2017 @10:33AM (#13327890)
Just for your reference, I've got Windows 10 and Powershell 5.1 running on an SSD (probably the only hardware that matters for program launch, really).

I can hit Win-X-I and start typing commands as fast as possible and Powershell is up instantly and I've never missed initial characters on a command. For interactive use, it's always there and up quickly.

This is in contrast to the typical start menu search which takes about a second before it registers keystrokes and I'm always searching for something missing the first few letters of the file or executable name.

Re:Rumors of Cmd’s death have been greatly exaggerated by ygra on Thursday January 05, 2017 @09:53AM (#13327492)
Windows 7 shipped with PowerShell v2. So yes, back then it was slow. It's not anymore.

Side note: A terminal emulator is completely different from a shell (and on Windows (prior to 10 at least) there wasn't such a thing, but rather the console, which did not emulate a terminal).

Re:Rumors of Cmd’s death have been greatly exaggerated by bloblaw on Thursday January 05, 2017 @11:55AM (#13328771)
Helge Klein wrote an excellent article "What I Hate About PowerShell": https://helgeklein.com/blog/2014/11/hate-powershell/

Be sure to read the comments where PowerShell guru Jeffrey Snover politely addresses them.

I share many of these same frustrations that have prevented me from adopting it as a Windows scripting language. I use it when I have to, but I still will choose csharp compiled EXE's, vbscript, or even Py2Exe'd Python programs over PowerShell for sysadmin type tasks.

I was in the audience at MS TechEd 2005 in Orlando and watched as Jeffrey Snover presented Monad and highlighted it's Perl, awk, sed, and unix influences. I was immediately impressed.

However, PowerShell seems to best fit as a REPL shell, and for me, more mentally cumbersome than using csharp (which of course can technically do everything ps can).

My gripes with PS are kind of minor (a bit like my dislike of Python's whitespace enforcement), but it's kind of like a death by a thousand annoyances with PowerShell for me.

For example (stolen from Helge's article), these are some WTF's for me

* Testing for string equality: "abc" -eq "abc" ( why isn't this "abc" == "abc" )

* Greater than: 8 -gt 6 ( why isn't this 8 > 6 ?)

* Functions can only be used after being defined. Leading to scenarios where a script begins waaaay down at the bottom.

* dynamic scoping: http://ig2600.blogspot.de/2010/01/powershell-is-dynamically-...

* No way to syntax check a PS script before it's run

These aren't all major, but the last one is a show-stopper for me. If I'm running a script on a couple hundred thousand machines (and I have) I can't afford to have my script bail out on an unexpected code-path.

I really like the idea of PowerShell, and I am honestly glad it exists, but I think it would benefit from some changes outlined in Helge's article.

And this is why me, someone working professionally with Windows for over 15 years (sysadmin, developer, security) doesn't choose to use PowerShell very often.

Re:Rumors of Cmd’s death have been greatly exaggerated by thoth on Thursday January 05, 2017 @12:23PM (#13329126)
> * Greater than: 8 -gt 6 ( why isn't this 8 > 6 ?)

Wouldn't that be ambiguous with ">" when used for redirecting IO?