Limitations of Windows PowerShell vs. Linux SSH/bash

By apexwm, 13 September, 2010 16:05

I've had the opportunity to work with PowerShell recently, on Windows 7. And I have to admit, I'm impressed with some things, but disappointed with others. It's young as far as software is concerned, so that may be part of this. I've worked with the Bash shell on Linux for many years, and now that I had to use PowerShell I've seen some limitations that are surprising. For instance, right away I noticed that PowerShell uses the same old telnet client that Windows 95 used. It's horrible. Especially with copy/paste. You have to go under the main menu, and select a "Mark" function, then select your text (which doesn't select line by line, it selects by cursor position). You have to go under the menu to do the Copy and Paste functions as well (no keyboard shortcuts that I know of). Simply archaic in my opinion.

On the flip side, SSH is extremely versatile and flexible. And here's why. First, you can use ANY SSH client you want. Personally, I use PuTTY. It's very lightweight, powerful, and has the features that work for me. Copy and paste is very efficiently done. Simply select the text (which is intelligent enough to select line by line, not by cursor position), and the text is automatically copied to the clipboard. Simply clicking the right mouse button (or center mouse button/wheel in Linux) will paste at the cursor position. I use this all of the time for editing documents in a shell, very very easy and powerful. This behavior is also done at the text terminal of Linux as well, with the "gdm" service on (allows the mouse to be used in the text terminal).

Another feature that I love with SSH is tunneling. It's basically a lightweight feature which allows access to TCP ports of machines inside the network of the SSH server. Local ports can be forwarded to remote ports. Works great for basic applications. The beauty of mapping these ports is that all traffic is tunneled through the SSH connection, which is all encrypted.

Tab completion in Bash is better in my opinion. You get a list of matching entries in Bash (by pressing Tab twice), so that you can type and narrow down to which command you want. PowerShell works the same as the old "command" prompt in Windows, where you have to subsequently press tab to scroll through each command one at at time to get the one you want. If you miss the one you want, you have to scroll through the entire list of matches again. In a list of more than 5 matches or so, it takes more time to use tab completion in PowerShell than it does to just try to look elsewhere.

These are very basic level observations with usability. There's a lot more to each shell once you dig into them more and what goes on in each.

 

Talkback

What about stuff like history handling (!command, !! and so on?), lists, extglobs?
lightpriest 14 September, 2010 10:32
Report offensive content Reply


lightpriest : Thank you for the comment, and for jogging my memory, I was going to mention the history and it slipped my mind. I was surprised to close a PowerShell window, then to go back in and repeat a few commands I had done earlier in the day. There were all gone! It was about that time that I recalled the PowerShell is using the same old command window from Windows 95. Linux shells (for those that don't know) keep a long history of commands and this can even be searched with a CTL-R. Here's a Bash reference page to give everybody an idea of what sort of functionality it has. It's an extremely powerful shell, which probably explains why it has been around so long: it's hard to perfect something that works so well.
apexwm 14 September, 2010 17:33
Edit Delete Report offensive content Reply


The Bash reference page is:

http://linuxhelp.blogspot.com/2005/08/bash-shell-shortcuts.html

Forgot that comments don't allow HTML...
apexwm 14 September, 2010 17:34
Edit Delete Report offensive content Reply


> It's horrible. Especially with copy/paste
If you go into the Properties of the command window, on the Options Tab, check the QuickEdit Mode.

> you have to subsequently press tab to scroll through each command one at at time
Check out "powertab". It is an addon for powershell that makes it work a lot more like Bash command-completion.
http://thepowershellguy.com/blogs/posh/archive/tags/PowerTab/default.aspx
LazerPotatoe 21 September, 2010 17:03
Report offensive content Reply


You got it all wrong. PowerShell is just a shell, the read-evaluate-print loop can be hosted by any environment just like bash. The regular "command prompt" indeed has support for "quick" cut-n-paste. Much more so in the PowerShell integrated scripting environment (ISE) which is a full-featured graphical environment with both scripting tabs, interactive prompt and interactive source level debugging.

It is also suspicious how you choose to focus on fringe topics (which has nothing to do with the shell) and completely ignore the powerfull PS features. Did you even take a look at PS remote administering support (remote commands, remote sessions and remote jobs)? It lets you seamlessly administer remote computers, issue powershell cmdlets, scripts etc. without even being concerned with SSH like functionality (which is *also* supported by PS).
honeymonster 26 September, 2010 09:45
Report offensive content Reply


honeymonster : Does ISE give you total control of a remote system (such as browsing the filesystem)? Or how about edit a file on the remote system? My point is, using SSH is like directly logging on to the remote system, you have total access for complete system administration. Powershell is an add-on, that interfaces with Windows, where scripts need to be written to access certain things and there is still a layer between your client and the actual root operating system.

My focus on the statements were on Powershell right out of the box. Sure, you can install an add-on for this, and an add-on for that. But when Microsoft releases patches for Powershell, do those add-ons all continue to work? What about upgrading Powershell to a newer version?

SSH is much much simpler by design, and taking advantage of the Bash shell in this example, gives you complete and direct access to the operating system.
apexwm 13 October, 2010 18:02
Edit Delete Report offensive content Reply


I give up using Windows shells years ago. On every Windows computer in our company we installed Cygwin: http://www.cygwin.com/ which enables you to use Unix/Linux commands. I also like to install vim editor: http://www.vim.org/download.php#pc
With this too software I can use Linux commands on Windows just like I would use Linux command on Linux.

I always do the following:
1. open file with vim editor
2. write bash command script
3. write simple Windows batch file (myfile.bat) with the following two commands:
dos2unix myfile.sh
bash myfile.sh
4. I create a schedule task to myfile.bat file.

When ever I edit sh file I am 100% sure that file was converted to Unix file when I execute Windows batch.

My suggestion is: If you are used to Unix/Linux bash commands don't waste time with Windows Power Shell, just use Cygwin. And one more advantage if you someday migrate your Windows system to Linux all your scripts will already be working.
jack001 15 October, 2010 14:16
Report offensive content Reply


>Does ISE give you total control of a remote system (such as browsing the filesystem)?

Yes. You can open a remote "tab" which essentially is just like SSH - only with less configuration if you want to auto-authenticate with your current credentials. Once there you can navigate the file system just like the local file system. Commands are issued remote and results are marshaled back to your primary console.

But you can also opt to use a remote session. This lets you step into and out from and back into the remote. Think suspend the SSH connection, bg, and bring it to the foreground again, only reliable (i.e. with no risk of losing pending IO).

PowerShell right out of the box has ISE. I am surprised you didn't notice that. No add-ons necessary.

>Or how about edit a file on the remote system?
Yes, you can manipulate files, content, etc. Now, can you start a GUI app and have it display locally? No. If that's what you want you really should compare SSH to RDP. That has nothing to do with the command shell.

With PowerShell I can collect performance for processes from a number of computers by typing:
icm -computer host1,host2,host3 {ps}
The result will be a list of all processes running on all of the hosts with a nice column for each process which tells me from which host it came. The command will execute simultaneously on all hosts and will only complete when all results have been collected. How do you do that with bash?
honeymonster 15 October, 2010 14:43
Report offensive content Reply


honeymonster : I've experienced problems when running certain commands in Powershell in the fashion you mention. For instance, there are known issues when running "xcopy" in Powershell on a remote system, even though it can be run locally without problems. To me this seems to be an issue with Windows not having a native shell tied closely enough to the operating system, but that's just my perception. I've never found a way to easily edit a remote file like I can in SSH by using "nano" or "vim", etc. which are very powerful remote editing utilities. Does Windows have a text-based file editing utility? This is one thing that I do very frequently in Linux. The thing that also bugs me about Windows is that a lot of files are in proprietary format so text editing/viewing utilities are worthless when trying to view event logs for example, etc.

"With PowerShell I can collect performance for processes from a number of computers by typing:
icm -computer host1,host2,host3 {ps}
The result will be a list of all processes running on all of the hosts with a nice column for each process which tells me from which host it came. The command will execute simultaneously on all hosts and will only complete when all results have been collected. How do you do that with bash?"

In order to list processes from multiple systems simultaneously, I would open up an SSH session to each system, view them side by side, and use the "ps" command on each system, or "top" which is the realtime process viewing utility.
apexwm 15 October, 2010 15:14
Edit Delete Report offensive content Reply


Windows telnet is a standalone application that ships as part of the OS. PowerShell has nothing to do with it except to launch it, just as you would from the DOS shell, an icon, the Start|Run menu, or any other way. The same way that an SSH/telnet client has nothing to do the bash/korn/etc shells. Comparing Windows telnet to an ssh client (and you don't say which ssh client) in a review of a command shell is irrelevant. And then to say that because Windows telnet is not good PowerShell is limited is just silly.

It almost sounds like your using the term ssh and bash interchangeably, which is wrong and confusing to the reader. You also obviously haven't used PowerShell enough to understand the benefits of working with objects instead of strings. That's common for experienced scripters looking at PowerShell for the first time, and forgiveable. It is the only forgiveable part of this article, unfortunately.

I'm guessing ZDNet UK doesn't have technical editors reviewing content before it's posted. Usually I just ignore and move on from bad articles, but the complete wrongness of this one got me so annoyed I had to comment.
ChrisZDNetUK 15 October, 2010 15:38
Report offensive content Reply


Forgot one point.
".. where you have to subsequently press tab to scroll through each command one at at time to get the one you want. If you miss the one you want, you have to scroll through the entire list of matches again."

Shift+Tab goes backwards. Before you say can't say "I don't know of a way" or "I don't think you can".
ChrisZDNetUK 15 October, 2010 16:11
Report offensive content Reply


ChrisZDNetUK :

"Comparing Windows telnet to an ssh client (and you don't say which ssh client) in a review of a command shell is irrelevant".

Actually I was comparing "command.exe" which seems to be the actual app used by the basic Powershell application itself, to Bash. Probably a mistake on my end, I should have mentioned "command.exe" rather than "telnet". I say this because the basic Powershell interface has the same menus and everything as the Command application in Windows. SSH clients are similar, my focus is on the SSH protocol and its connectivity to a remote system to allow a seamless connection. The actual SSH client is a little outside of the scope here.

"It almost sounds like your using the term ssh and bash interchangeably, which is wrong and confusing to the reader."

I use them in combination because this is the solution to provide a remote shell on a Linux system. Same as with Powershell, again, a remote shell solution.

"You also obviously haven't used PowerShell enough to understand the benefits of working with objects instead of strings. "

You are correct. The focus is administration of a remote system as if I was directly on that system, and having a remote shell in comparison, as well as overall usability. Not learning the extra layer of Powershell's object scripting and commands necessarily. I suppose you could say that I should have compared Powershell locally and remotely which would be a valid argument.
apexwm 15 October, 2010 16:24
Edit Delete Report offensive content Reply


"Shift+Tab goes backwards. Before you say can't say "I don't know of a way" or "I don't think you can"."

Thanks for the tip and a good point. Personally, I find it more useful where Bash gives you a complete list so that you can simply continue to type the matching pattern, then hit Tab again to see what additional matches you get, allowing you to narrow down to whichever one you want. Scrolling through a list one line at a time to me is counterproductive. What if you have 50 matches? Are you going to scroll 50 individual lines trying to narrow down wich one you are looking for? But this is just my opinion.
apexwm 15 October, 2010 16:28
Edit Delete Report offensive content Reply


> I've experienced problems when running certain commands in Powershell in the fashion you mention.
Citation needed. Anyway, there's a proper command for that: Copy-Item. It has an alias: copy. Type "help copy" next time you open PowerShell (CLI or ISE). Please note that Copy-Item is generalized and will copy *any* type of item - not just files or folders. I.e. if you step into the registry, certificate store, or any 3rd party PsDrive provider (e.g. SQL server, VMWare etc) it will work the same.

>Does Windows have a text-based file editing utility?

No, not built-in. Nothing to do with PowerShell, though. Relevance? I will use PowerShell to script the local system or remote systems. You bring in SSH (as if that's part of bash?) and fails to recognize that those are orthogonal issues. Telnet works on Windows, too.

But when you try to diss PowerShells remoting capabilities by referring to SSH you really just display your ignorance about PowerShell and the distinction between remote channels (ssh) and command line interpreters. As Chris said, you mix the terms.

Quite frankly, PowerShells remote admin capabilities blows bash/ssh out of the water. I gave you an example above how PS supports "fan out" remoting - simultaneous execution on several machines. Here's another:
icm host1,host2,host2 backup.ps1
This will execute the backup.ps1 script 3 hosts simultaneously. It need not exist on the remote computers.

How do ssh+bash handle remote jobs? Want to execute a script on a remote computer but as a job which you can control from your local console?
icm host1 backup1.ps1 -asjob

You see - you rarely need to actually "jump" to the remote computer. You can just issue commands. Makes ssh look utterly dated...
honeymonster 15 October, 2010 16:34
Report offensive content Reply


"> I've experienced problems when running certain commands in Powershell in the fashion you mention.
Citation needed."

Here's a similar issue to the one mentioned in this thread:

http://stackoverflow.com/questions/1773108/powershell-ise-appears-to-hand-with-interactive-commands

It's also mentioned in this thread that "Interactive console applications are not supported in ISE". This is limitation in my opinion, if this is correct.

"But when you try to diss PowerShells remoting capabilities by referring to SSH you really just display your ignorance about PowerShell and the distinction between remote channels (ssh) and command line interpreters. As Chris said, you mix the terms."

Well, my general focus was with remote administration using a command line, based on common tasks that I handle. On Linux, I would use SSH with the Bash shell. On Windows, I would use Powershell. This is the basis for my comparison. The example that prompted me to put up the article was with remote administration of two mail servers, one with Exchange using the Exchange Management Shell (Powershell), and a Linux Sendmail server using SSH/Bash. Everybody will use different tools depending on preference. Overall, I find Powershell more clumsy as a whole for remote administration, than I do SSH/Bash for remote administration.

I guess you have to step back and ask yourself what types of admin tasks you commonly handle. Commonly, I need to edit text files on a remote system, or do a simple find/replace in them. We've admitted here there's no easy way to view/edit files directly in Powershell. Another one even more frequently is to view logs. Viewing logs will vary in Windows, depending on which log(s) you need to view (i.e. Event Log, IIS log, etc.). I find it cumbersome having to use different Powershell utilities to view different logs, where on a Linux server all logs are in text format so one tool can be used. This however is getting out of the scope.

I also re-read ChrisZDNetUK's comment : "Comparing Windows telnet to an ssh client (and you don't say which ssh client) in a review of a command shell is irrelevant".

Well, I admit I should have mentioned "command.exe" instead of telnet in my original article. I was comparing a Powershell window to a PuTTY window in that example.
apexwm 15 October, 2010 17:39
Edit Delete Report offensive content Reply


"We've admitted here there's no easy way to view/edit files directly in Powershell"

PS> Invoke-Item \\servername\C$\path\logfilename.txt
The above command should open the remote file in notepad (using the default text editor application). This uses the adminstrative file share for the C drive. You need to have admin rights on the server.


PS> Get-EventLog -LogName System -EntryType Error -Newest 5 -computerName "MY_SERVER_NAME"
The above command will show the latest 5 error events from the System log.


Also, you can use the command Select-String in a similar way to grep. I don't think it can do search and replace however. But you could write a simple script.

Sorry -- I know you're trying to hate Powershell -- but it's actually pretty slick. I am still a big fan of Linux and Perl though.

Best Regards
LazerPotatoe 15 October, 2010 20:53
Report offensive content Reply


In my personal opinion articles like these do not belong on the web. I am not really sure how these 5 paragraphs were even published.

The article makes a grand statement that it is comparing two products, however the article covers such a small subset of the overall functionality that it provides very little (if any) value.

The best comparison I can think of for this article is as follows:
Comparing two cars and talking of the limitations of one of the cars and then just comparing how the windscreen wiper controller levers and the indicators work. Without considering the Engine, the Body, the Efficiency, the Interior, the Performance, the Purpose etc etc etc.

In short this article is one of the shallowest articles I have ever read.
1000274476 16 October, 2010 00:30
Report offensive content Reply


> In short this article is one of the shallowest articles I have ever read.
Agreed. And what little substance it has; it got mostly wrong, like failing to observe the difference between channel (ssh) and processor (bash/powershell).
honeymonster 16 October, 2010 10:11
Report offensive content Reply


apexwm wrote (15 October, 2010):
> Commonly, I need to edit text files on a remote system,
> or do a simple find/replace in them. We've admitted here there's no easy way
> to view/edit files directly in Powershell.

The point that others have made is that you don't need to edit remotely because you can edit locally (using vim OR something as fancy as ISE) and run on any host, seamlessly. Anyways it seems to me that's even better than what ssh supports.

I say this despite having been pro-Linux and anti-Windows for years... but Windows has come a long way. And I had to smile when I saw the help system in Powershell; clearly borrowed from Unix!
schollii 1 April, 2011 20:39
Report offensive content Reply


@schollii
>The point that others have made is that you don't need to edit remotely because
>you can edit locally (using vim OR something as fancy as ISE) and run on any host,
>seamlessly. Anyways it seems to me that's even better than what ssh supports.

Uhm. Exactly. And, PowerShell's remoting features allow you remotely execute script blocks on any number of computers simultaneously. Indeed, you can write a script file locally and use Invoke-Command to execute it remotely. PowerShell will transfer the script and execute remote and consolidate the results back.

PowerShells help system indeed seems Unixy-like. It lags a little, though, as you cannot page forward and backward - it only goes forward. The help system as such is much more advanced, though. PS will automatically pick up parameter names, types and validation and document those in the help. Comment-based help (comments following a special "dot" syntax) is automatically picked up by the help system. It is all single-file, i.e. your help text goes right in with the cmdlets or function definitions. This is true even for script files.
honeymonster 14 April, 2011 18:59
Report offensive content Reply


Part of my point was to mention easy administration of a remote system. SSH is a very lightweight client that I can use to do practically anything for remote administration from any machine regardless of platform (Mac OS X, Linux, Windows, etc.), and even without any software installation necessary. Can a Powershell client be installed and fully functional on a Mac or Linux platform? Not entirely from what I have seen. And there are other workarounds to try and administrate Windows systems from Linux and Mac OS X, that use, surprise, SSH.
apexwm 28 April, 2011 18:41
Edit Delete Report offensive content Reply


>Part of my point was to mention easy administration of a remote system"

Easy administration of remote system? The easiest way is to use a declarative or rule-based approach which will not require you to connect to the system and execute scripts in the first place. I understand why you would want to skip over this fact (not available with your Linux). GPOs in Windows takes care of 90%+ of your need to ever run a script at a remote.

>SSH is a very lightweight client that I can use to do practically anything for remote administration
>from any machine regardless of platform (Mac OS X, Linux, Windows, etc.)

Yes, and SSH is also available for Windows (OpenSSH). That was one of my points above: SSH has *nothing* to do with bash nor PowerShell; they are orthogonal issues. Yet you tried to pit SSH against PowerShell. However, Windows has better options than SSH built-in, specifically it has an implementation of the industry standard WS-Management protocol.

PowerShell has fan-out remoting, remote sessions, implicit remoting and (single) remote commands built-in. Bash really only allows you to remotely connect to a host and run commands there. Compared to PowerShell, this is a limited model. Essentially what you can do with bash/SSH is comparable to (part of) remote sessions and remote commands.

>Can a Powershell client be installed and fully functional on a Mac or Linux platform?
There is no such thing as a "Powershell client". As stated above, you can use SSH, telnet or whatever to remotely connect to a PowerShell prompt. You don't *need* a PowerShell "client" - you can still use the same *basic* remoting model as with bash/SSH: Connect and interact with the remote process through stdin/-out. But *if* you happen to have PowerShell on both machines you can immediately use a much *richer* remote control model. It is not an either/or.

>And there are other workarounds to try and administrate Windows systems from Linux
>and Mac OS X, that use, surprise, SSH.
Yes, even PowerShell can be used over SSH. Which flies in the face of your original attempt to pit SSH as an advantage over PowerShell - even though SSH can be used with PowerShell like with bash.
honeymonster 3 May, 2011 22:15
Report offensive content Reply


Well I look after some windows boxen. And I must say it is much faster to work with a few installed tools like cygwin and pstools etc, than the native windows crap. I have used a little bit of "windows scripting host", monard, "Power shell". The name of the same solution has changed over the years in windows. But its the same stuff. The bash/unix technologies just don't get the way of doing stuff. Using shared ssh keys it is easy to emulate the example given a few posts above.
Example:
for server in windows1 windows2 windows3
do
echo " -------- $server --------"; ssh $server psloglist -s system | head -n5
done

The Microsoft solutions tend to be very limited in what thay can do. The open source way opens up a vast toolset that is easy to use, from remote systems.

Bash and tools win!
steveee 4 May, 2011 14:51
Report offensive content Reply