News for hackers. Stuff that matters.
Re:Microsoft Replaces Command Prompt with PowerShell in Late... by pawadu on Friday November 18, 2016 @08:20AM (#12986509)
So basically instead of doing

    dir C:\
I have to learn to type

   List-Directory-With-Files Drive=C Folder=/
(made up example, but you get the point)
Re:Microsoft Replaces Command Prompt with PowerShell in Late... by bhouston on Friday November 18, 2016 @08:25AM (#12986543)
Both DIR and LS do list directories in PowerShell.

But all parameters on DIR and LS seem to result in errors, even "dir /h", "dir /?", "dir -h", "dir --help", etc. That is a bit annoying.

Re:Microsoft Replaces Command Prompt with PowerShell in Late... by sapphire_tomb on Friday November 18, 2016 @09:08AM (#12986820)
DIR and LS are both aliases for Get-ChildItem, which doesn't support the flags you're after.
Re:Microsoft Replaces Command Prompt with PowerShell in Late... by kuschku on Friday November 18, 2016 @09:48AM (#12987072)
Then don't make them aliases, if they're not the same.

The issue already happened with cURL.

Re:Microsoft Replaces Command Prompt with PowerShell in Late... by eriknstr on Friday November 18, 2016 @10:55AM (#12987591)
They are aliases for Get-Children. Just like you can have an arbitrary alias for anything on UNIX. If I so pleased I could make an alias so that when I wanted to delete a file I'd type

  emacs some-old-file-i-dont-want.c
Emacs would be an alias for rm on my system.

That being said I think it was quite offensive of MS to use wget and curl as aliases, even though they may have had no ill intentions. I'm ok with using ls and echo and names of other such basic commands as aliases, but with tools like wget and curl that are known for their vast array of useful features you either implement their features and options or you don't use their names.

Re:Microsoft Replaces Command Prompt with PowerShell in Late... by kuschku on Friday November 18, 2016 @11:17AM (#12987777)
> I'm ok with using ls and echo and names of other such basic commands as aliases, but with tools like wget and curl that are known for their vast array of useful features

Well, I can't do my typical ls -la either.

Re:Microsoft Replaces Command Prompt with PowerShell in Late... by erk__ on Friday November 18, 2016 @08:48AM (#12986684)
help( / man / Get-help) dir brings up the help menu for Get-ChildItem
Re:Microsoft Replaces Command Prompt with PowerShell in Late... by taspeotis on Friday November 18, 2016 @08:24AM (#12986536)
Re:Microsoft Replaces Command Prompt with PowerShell in Late... by pawadu on Friday November 18, 2016 @08:40AM (#12986637)
Sure, go ahead, ruin my joke :)

More seriously, how many seconds did it took for the PS to answer to that command?

Re:Microsoft Replaces Command Prompt with PowerShell in Late... by taspeotis on Friday November 18, 2016 @08:43AM (#12986658)

    Measure-Command {dir C:\}
    TotalMilliseconds : 2.9708

    Measure-Command {Get-ChildItem "C:\"}
    TotalMilliseconds : 2.4161
Re:Microsoft Replaces Command Prompt with PowerShell in Late... by jeeva on Friday November 18, 2016 @11:23AM (#12987832)
I feel like I should point out that `Measure-Command {dir C:\}` is just aliasing gci.

    PS> Measure-Command {Start-Process cmd -ArgumentList '/c dir c:\'}
    TotalMilliseconds : 14.0138

    PS> Measure-Command {gci C:\}
    TotalMilliseconds : 10.7484
Second run on each of those went down to closer to 40% of each, yay caching.

Of course, the start-process is possibly taking up a chunk of time, there. With no measure-command for cmd, it makes it a little harder to gauge.

Re:Microsoft Replaces Command Prompt with PowerShell in Late... by pritambaral on Friday November 18, 2016 @09:37AM (#12987003)
Compare it with cmd.exe's dir
Re:Microsoft Replaces Command Prompt with PowerShell in Late... by Already__Taken on Friday November 18, 2016 @10:04AM (#12987189)

  c:\temp>timecmd dir c:\
  Volume in drive C is Windows
  Volume Serial Number is A0A8-6684

  Directory of c:\

  01/11/2016  12:45    <DIR>          AMD
  ...
  17/11/2016  12:52    <DIR>          Windows
                 9 File(s)         25,337 bytes
                18 Dir(s)  71,423,356,928 bytes free
  command took 0:0:0.08 (0.08s total)
bat from http://stackoverflow.com/a/6209392
Re:Microsoft Replaces Command Prompt with PowerShell in Late... by taspeotis on Friday November 18, 2016 @09:57AM (#12987131)
I have had a quick look through here [1] and most of the answers involve timing precision of two significant digits. By that metric, PowerShell's 2.4ms clocks in at 0.00 seconds. Which means cmd.exe (at a precision of two significant digits) can't beat it.

[1] http://stackoverflow.com/questions/673523/how-to-measure-exe...

Re:Microsoft Replaces Command Prompt with PowerShell in Late... by Arnavion on Friday November 18, 2016 @04:24PM (#12990207)
"2.4" or "0.0024" or "24000" all have two significant digits. Leading and trailing zeros don't count as significant digits.
Re:Microsoft Replaces Command Prompt with PowerShell in Late... by taspeotis on Friday November 18, 2016 @06:32PM (#12990925)
My mistake, you are right [1]. Thanks for the correction.

[1] https://en.m.wikipedia.org/wiki/Significant_figures

Re:Microsoft Replaces Command Prompt with PowerShell in Late... by jodrellblank on Friday November 18, 2016 @01:14PM (#12988786)
and find that command prompt dir is faster because it's doing less, because it's less capable. It's not creating System.IO.FileInfo and DirectoryInfo objects for each thing in the directory.
Re:Microsoft Replaces Command Prompt with PowerShell in Late... by 0xfeba on Friday November 18, 2016 @10:49AM (#12987535)
Second time the HD has probably cached the result...
Re:Microsoft Replaces Command Prompt with PowerShell in Late... by snuxoll on Friday November 18, 2016 @11:21AM (#12987815)

    Measure-Command { gci C:\ }
    TotalMilliseconds : 1.3334
It's pretty fast
Re:Microsoft Replaces Command Prompt with PowerShell in Late... by douche on Friday November 18, 2016 @08:44AM (#12986664)
At least Powershell has Unixy aliases for the common commands.

I don't know how many times I've been in a cmd shell and typed ls and then swore at things.

Re:Microsoft Replaces Command Prompt with PowerShell in Late... by cableshaft on Friday November 18, 2016 @09:19AM (#12986896)
I just wrote batch files that serve as aliases for those. I type ls in my command shell and it does a dir /w behind the scenes, which makes it look more like how it looks in Linux anyway. Here are the ones I have:

* cat.bat: type %1

* clear.bat: cls

* diff.bat: fc /n /w %1 %2

* ls.bat: dir /w %1%

* pwd.bat: cd

* touch.bat: echo . >> %1

* top.bat: tasklist

All have an @echo off at the top too. Touch is a little janky, because I couldn't figure out how to actually create an empty file with nothing in it from the command prompt.

I'm actually not really a Linux person, but on Mac you kinda have to use these, so I got more used to using them than the Windows counterparts.

Re:Microsoft Replaces Command Prompt with PowerShell in Late... by ygra on Friday November 18, 2016 @09:45AM (#12987053)

    copy nul %1 >nul
to get an empty file. It's not a replacement for touch, though, as touch will do something different to existing files. Your attempt will silently overwrite the file in that case.
Re:Microsoft Replaces Command Prompt with PowerShell in Late... by jeeva on Friday November 18, 2016 @11:27AM (#12987874)
Couldn't you just append null to a given filepath to get the same result, or am I misguidedly assuming that >> creates files that don't exist?
Re:Microsoft Replaces Command Prompt with PowerShell in Late... by ygra on Friday November 18, 2016 @12:18PM (#12988301)
Interesting idea, but type nul >> file doesn't change the metadata, perhaps because nothing was written. But yes, it would at least not destroy files.
Re:Microsoft Replaces Command Prompt with PowerShell in Late... by erikbye on Friday November 18, 2016 @10:39AM (#12987455)
Re:Microsoft Replaces Command Prompt with PowerShell in Late... by Senji on Friday November 18, 2016 @11:09AM (#12987708)
You could put the @ in front of the command like so:

1 line file: @type %1

Re:Microsoft Replaces Command Prompt with PowerShell in Late... by benaadams on Friday November 18, 2016 @10:26AM (#12987351)
Add posh-HumpCompletion https://github.com/stuartleeks/posh-HumpCompletion then you just need to type first Caps and hit tab
Re:Microsoft Replaces Command Prompt with PowerShell in Late... by chokolad on Friday November 18, 2016 @10:36AM (#12987426)
You can do the same thing with PSReadline, which is included in Win 10 installs.
Re:Microsoft Replaces Command Prompt with PowerShell in Late... by Tarean on Friday November 18, 2016 @11:08AM (#12987695)
No, dir `c:\ works` just fine.

It is a short version for

    Get-ChildItem -Directory C:/
Re:Microsoft Replaces Command Prompt with PowerShell in Late... by UK-AL on Friday November 18, 2016 @09:14AM (#12986861)
first command works perfectly fine under powershell.
Re:Microsoft Replaces Command Prompt with PowerShell in Late... by Senji on Friday November 18, 2016 @11:08AM (#12987697)

    ls c:\ 
or gci c:\
Re:Microsoft Replaces Command Prompt with PowerShell in Late... by kierenj on Friday November 18, 2016 @08:52AM (#12986709)
Nope - what makes you think that?
Re:Microsoft Replaces Command Prompt with PowerShell in Late... by cm2187 on Friday November 18, 2016 @09:17AM (#12986880)
Being verbose would be a good thing (more readable than a cryptic acronym) if there was auto-complete support. A console should really be a small IDE that gives live feedback on what arguments are possible in the current context, etc. But that's not the way powershell was designed.
Re:Microsoft Replaces Command Prompt with PowerShell in Late... by ygra on Friday November 18, 2016 @09:42AM (#12987038)
Actually, that's exactly how PowerShell was designed. Have you tried pressing <Tab>? Every command can be inspected and you get auto-completion support by default, for commands, parameters, even properties on returned objects (since the shell often knows what type is returned from a command).
Re:Microsoft Replaces Command Prompt with PowerShell in Late... by captainmuon on Friday November 18, 2016 @09:33AM (#12986985)
There is auto-complete support. I just tested it (not a powershell user myself), and it seems pretty intelligent.

For example, if you type

    dir | sort <TAB>
it suggests Attributes, BaseName, CreationTime, .... All properties of file objects (which is what dir returns).

Also there is PowerShell ISE, which is a IDE for powershell, but I haven't really tried it yet.

Re:Microsoft Replaces Command Prompt with PowerShell in Late... by cm2187 on Friday November 18, 2016 @09:59AM (#12987149)
That's not what I mean by autocomplete. What I mean is more like Visual Studio's intellisense, ie a drop down that lets you know what are all the options from there. You can type DIR <TAB>, that won't tell you that you can apply the parameters "/p" or "/w" nor what these parameters mean. ISE does a slightly better job but is based on a static specs, rather than the current state of the system. So it won't list the VM names currently active in the system for instance.

Yes you can type -?, but that's as bad as having to go on the web to read the documentation. It's disruptive. The point of a good auto-complete is to have a list at your fingertips with a short description of what it does, without interrupting your train of thought.

Re:Microsoft Replaces Command Prompt with PowerShell in Late... by NetStrikeForce on Friday November 18, 2016 @10:13AM (#12987250)
That's exactly how it works!

You can press ctrl+space and it pops out a list of options to choose from, then you move with the arrow keys. It works for parameters and values (if there's a set to choose from):

I've taken a screenshot to illustrate: http://i.imgur.com/d7MVYma.png

Re:Microsoft Replaces Command Prompt with PowerShell in Late... by Rynant on Friday November 18, 2016 @10:16AM (#12987277)
If you type: dir -<Ctrl+Space> PowerShell will list all available parameters below, and allow you to tab through them.

The tab completion is not static either. If you type: ps <Tab>, it will tab through all the current processes.

Re:Microsoft Replaces Command Prompt with PowerShell in Late... by cm2187 on Friday November 18, 2016 @10:38AM (#12987438)
I you type "Start-VM -name <TAB>", it won't list the list of the VMs, but rather the list of the files in the current directory. That's not exactly what I would call insightful.

I didn't know about the CTR+SPACE. That being said it doesn't seem much more insightful than TAB. And no description of what the argument does.

Re:Microsoft Replaces Command Prompt with PowerShell in Late... by Rynant on Friday November 18, 2016 @11:14AM (#12987746)
The issue with "Start-VM -name <TAB>" is not an issue with Powershell itself, but with the Start-VM cmdlet; the Start-VM cmdlet could have been designed to complete from the list of VMs.
Re:Microsoft Replaces Command Prompt with PowerShell in Late... by Already__Taken on Friday November 18, 2016 @10:09AM (#12987224)
The ise can do that if you've got the object at the time you're writing like that, it can't run a command for you as your typing it.

You'll never get a drop down list in the host terminal windows has it doesn't have a GUI layer like that. Wrap it in a electron app and make one.

you can type `dir -<tab>` and cycle through the options. type `get-help dir` to see what they do or install posh-git and use `dir -<ctrl-space>` to get a menu of options to choose. I didn't know about -?

Re:Microsoft Replaces Command Prompt with PowerShell in Late... by jodrellblank on Friday November 18, 2016 @01:17PM (#12988817)
You'll never get a drop down list in the host terminal windows has it doesn't have a GUI layer like that.

Except you do, with PSReadline, built into Windows 10 PowerShell.

Re:Microsoft Replaces Command Prompt with PowerShell in Late... by Already__Taken on Saturday November 19, 2016 @04:28AM (#12992699)
Sorry yes that's psreadline not posh-git like I commented. I wouldnt' call that a drop down though, that's just adding to the output isn't it? You know I've no idea how that works, could come in handy actually I should learn.
Re:Microsoft Replaces Command Prompt with PowerShell in Late... by jodrellblank on Saturday November 19, 2016 @02:44PM (#12995220)
It's as close to a dropdown as you can get in the CLI without putting GUI elements over the top. Try

    gci -  then ctrl+space
The available parameters appear on the screen, you can select one with the arrow keys, and tab, when you choose one and press space, they all disappear again. It's interactive, dynamic, it changes depending on how much of the parameter name you've typed - it's not just printing to the screen and stuck there.
Re:Microsoft Replaces Command Prompt with PowerShell in Late... by oblio on Friday November 18, 2016 @09:47AM (#12987064)
Have you even used Powershell? :)