Take the 2-minute tour ×

I'm debating whether I should learn PowerShell, or just stick with Cygwin/Perl scripts/Unix shell scripts, etc.

The benefit of PowerShell would be that the scripts could be more easily used by teammates that don't have Cygwin; however, I don't know if I'd really be writing that many general purpose scripts, or if people would even use them.

Unix scripting is so powerful, does PowerShell come close enough to warrant switching over?

Here are some of the specific things (or equivalents) I would be looking for in PowerShell:

  • grep
  • sort
  • uniq
  • Perl (how close does PowerShell come to Perl's capabilities?)
  • AWK
  • sed
  • file (the command that gives file information)
  • etc.
share|improve this question
I wouldn't say that, I was interested in picking up Powershell, found this page, and now I know the general differences between PS and the shell scripting I'm used to. –  Alexander Miles Jul 16 '11 at 16:58
This post suddenly rose from ashes in a HN link submission. Great work. And bad for @Bobby for closing this as not constructive. –  Sid Jul 13 '12 at 14:27
If someone cannot ask how well one tool replicates the functions of another then S.O. cannot answer tool comparison questions. This is carefully worded to avoid controversy but was careless presumed "controversial" simply for looking like a Unix vs Windows question. And it got a factual, objective answer, with additional factual insight into how helpful Unix scripting might be on Windows. –  chernevik Jul 13 '12 at 15:16
Why is this closed, again? Someone please edit the title to say "PowerShell vs Unix Shells on the Windows Platform" to steer the trolls away from treating it as "Windows vs Unix," which it is not. This is a perfectly constructive question - voted to reopen. –  x0n Jul 16 '12 at 6:14
I agree with the other commenters that believe this is a valid question with some helpful (and very popular) answers. –  Keith Hill Jul 16 '12 at 15:47

16 Answers 16

up vote 527 down vote accepted

Tools are just tools.
They help or they don't.
You need help or you don't.

If you know Unix and those tools do what you need them to do on Windows - then you are a happy guy and there is no need to learn PowerShell (unless you want to explore).

My original intent was to include a set of Unix tools in Windows and be done with it (a number of us on the team have deep Unix backgrounds and a healthy dose of respect for that community.) What I found was that this didn't really help much. The reason for that is that awk/grep/sed don't work against COM, WMI, ADSI, the Registry, the cert store, etc, etc. In other words, UNIX is an entire ecosystem self-tuned around text files. As such, text processing tools are effectively management tools. Windows is a completely different ecosystem self-tuned around APIs and Objects. That's why we invented PowerShell.

What I think you'll find is that there will be lots of occasions when text-processing won't get you what you want on Windows. At that point, you'll want to pick up PowerShell. NOTE - it is not an all or nothing deal. Within PowerShell, you can call out to your Unix tools (and use their text process or PowerShell's text processing). Also you can call PowerShell from your Unix tools and get text.

Again - there is no religion here - our focus is on giving you the tools you need to succeed. That is why we are so passionate about feedback. Let us know where we are falling down on the job or where you don't have a tool you need and we'll put it on the list and get to it. In all honesty, we are digging ourselves out of a 30 year hole so it is going to take a while. That said, if you pick up the beta of Windows Server 2008 /R2 and/or the betas of our server products, I think you'll be shocked at how quickly that hole is getting filled.

With regard to usage - we've had > 3.5 million downloads to date. That does not include the people using it in Windows Server 2008 because it is included as an optional component and does not need a download. V2 will ship in all versions of Windows. It will be on-by-default for all editions except Server core where it is an optional component. Shortly after Windows 7/Windows Server 2008 R2 ships, we'll make V2 available on all platforms XP and above. In other words - your investment in learning will be applicable to a very large number of machines/environments.

One last comment. If/when you start to learn PowerShell, I think you'll be pretty happy. Much of the design is heavily influenced by our Unix backgrounds so while we are quite different, you'll pick it up very quickly (after you get over cussing that it isn't Unix :-) ). We know that people have a very limited budget for learning - that is why we are super hard-core about consistency. You are going to learn something and then you'll use it over and over and over again.

Experiment! Enjoy! Engage!

Jeffrey Snover [MSFT] Windows Management Partner Architect

share|improve this answer
@Jeffrey Welcome to StackOverflow! –  Steven Murawski Feb 22 '09 at 6:07
Thanks for your answer. I think I'm going to go ahead and learn PowerShell. It looks powerful from what I've seen so far, and I'll be able to write more useful scripts with it at work. –  Andy White Feb 23 '09 at 0:20
@Jeffrey: is there a chance for a better terminal for Windows? Powershell is a powerful scripting language, but the fact it runs in cmd.exe makes it much more convenient in the interactive mode –  sumek Jul 7 '10 at 10:23
This "not constructive" question generated the best insight I've seen into the whole "on Unix everything is a file" mantra, and why Windows is different. Maybe StackOverflow would be better served closing not constructive discussions? –  chernevik Jul 13 '12 at 14:51
@sumek - Give ConEmu a try; I've been using it for a few weeks and it's pretty sweet: hanselman.com/blog/… –  E.Z. Hart Jul 13 '12 at 17:43


Select-String cmdlet and -match operator work with regexes. Also you can directly make use of .NET's regex support for more advanced functionality.


Sort-Object is more powerful (than I remember *nix's sort). Allowing multi-level sorting on arbitrary expressions. Here PSH's maintenance of underlying type helps; e.g. a DateTime property will be sorted as a DateTime without having to ensure formatting into a sortable format.


Select-Object -Unique

Perl (how close does PowerShell come to Perl capabilities?)

In terms of Perl's breadth of domain specific support libraries: nowhere close (yet).

For general programming, PSH is certainly more cohesive and consistent, and easier to extend. The one gap for text munging is something equivalent to perl's .. operator.


It has been long enough since using awk (must be >18 years, since later I just used perl), so can't really comment.


[See above]

file (the command that gives file info)

PSH's strength here isn't so much of what it can do with filesystem objects (and it gets full information here, dir returns FileInfo or FolderInfo objects as appropriate) is that is the whole provider model.

You can treat the registry, certificate store, SQL Server, IE's RSS cache etc. as an object space navigable by the same cmdlets as the filesystem.

PSH is definitely the way forward on Windows. MS have made it part of their requirements for future non-home products. Hence rich support in Exchange, support in SQL Server, this is only going to expand.

A recent example of this is the TFS PowerToys. Many TFS client operations are done without having to startup tf.exe each time (which requires a new TFS server connection etc.) and is notably easier to then further process the data. As well as allowing wide access to the whole TFS client API to a greater detail than exposed in either Team Explorer of TF.exe.

share|improve this answer
The thing is that the provider model is interesting only because the OS doesn't use text as its universal config medium, so you NEED these providers. With UNIX most languages have APIs to touch PAM, hosts, and packages, but ultimately text will always be there. –  Daishiman Feb 21 '09 at 23:44
Text is not always the best format for everything (start with databases and raster images). But I think we can agree to disagree rather than open format wars. –  Richard Feb 22 '09 at 0:06
Powershell can use any object in the .NET framework, doesn't this match Perl's domain capabilities? Plus you can write cmdlets in C# etc. if you want re-usability –  Chris S May 30 '13 at 15:01

As someone who's career focused on Windows enterprise development from 1997 - 2010 the obvious answer would be Powershell for all the good reasons given above (e.g. It is part of MS' enterprise strategy; it integrates well with Windows/COM/.NET; and using objects instead of files provides for a "richer" coding model). For that reason I'd been using and promoting Powershell for the last 2 years or so, with the express belief I was following the "Word of Bill."

However, as a pragmatist I'm no longer sure Powershell is such a great answer. While it's an excellent Windows tool and provides a much needed step towards filling the historic hole that is the Window command line, as we all watch MS' grip on consumer computing slip it seems increasingly likely that MS has a massive battle ahead to keep it's OS as important to the enterprise of the future.

Indeed, given I find my work is increasingly in heterogeneous environments, I'm finding it much more useful to use bash scripts at the moment, as they not only work on Linux, Solaris and Mac OS X, but they also work—with the help of Cygwin—on Windows.

So if you buy into the belief that the future of the OS is commoditized rather than a monopolized, then it seems to make sense to opt for an agile development tool strategy that keeps away from proprietary tools where feasible. If however you see your future being dominated by all-that-is-Redmond then go for Powershell.

share|improve this answer

I have used a bit of PowerShell for script automation. While it is very nice that the environment seems to have been thought out much more than Unix shells, in practice the use of objects instead of text streams is much more clunky, and a lot of the Unix facilities that have been developed in the last 30 years are still missing.

Cygwin is still my scripting environment of choice for Windows hosts. It certainly beats the alternatives in terms of getting things done.

share|improve this answer
Using objects is a paradigm shift and takes some getting used to. But avoids the whole re-parsing at each step where structured data is involved (e.g. no need to ensure fields are delimited). –  Richard Feb 21 '09 at 21:22
@Andy White @Daishiman, I can understand where there is a learning curve with PowerShell, but piping objects can be much more flexible than piping text. @Richard is correct. :) –  Steven Murawski Feb 21 '09 at 22:28
Auto makers had a hard time arguing with 1000+ years of horses too. I'm not trying to be flippant. Just pointing out that past success does not remove the potential benefit of innovation. –  EBGreen Feb 21 '09 at 23:04
@daishiman - The benefit of Objects is that when you want a property, you ask for it - you don't have to parse,guess,cast. I did not understand your point about "what happens when objects don't have compatible methods" - Could you say that another way or give an example of the problem? Thanks. –  Jeffrey Snover - MSFT Feb 22 '09 at 0:33
@Daishiman - I understand. In practice people have found this not to be a problem but rather a huge advantage. That said, I can see that if you were an expert text parser, this would be a new skill to learn and it might feel unneeded and awkward at first. Again - whatever helps is the right tool. –  Jeffrey Snover - MSFT Feb 22 '09 at 1:21

I am not a very experienced PowerShell user by any means, but the little bit of it that I was exposed to impressed me a great deal. You can chain the built-in cmdlets together to do just about anything that you could do at a Unix prompt, and there's some additional goodness for doing things like exporting to CSV, HTML tables, and for more in-depth sys-admin types of jobs. And if you really needed something like sed, there's always UnixUtils or GnuWin32, which you could integrate with Powershell fairly easily.

As a longtime Unix user, I did however have a bit of trouble getting used to the command naming scheme, and I certainly would have benefitted more from it if I knew more .NET.

So essentially, I say it's well worth learning it if the Windows-only-ness of it doesn't pose a problem.

share|improve this answer
There is an open source project "Pash" that lets you run PowerShell on other platforms via Mono. tinyurl.com/6dyoso –  John D. Cook Feb 21 '09 at 20:46
Whoa! Thanks for the tip; I can't wait to give it a try –  yalestar Feb 21 '09 at 22:29
+1 for mentioning gnuwin32 –  MeaCulpa Oct 24 '12 at 4:37

When you compare PowerShell to the combination Cygwin/Perl/Shell, be aware that PowerShell only represents the "Shell" part of that combination.

You can however invoke any command from PowerShell just as you do from cmd.exe or Cygwin. It does not re-implement the specified functions, and it is certainly not comparable to Perl.

It's "just" a shell, but it makes programming easier providing a comfortable interface to the .Net universe.

Also keep in mind that PowerShell requires WinXP, Srv2003 or higher, which may pose a problem depending on your IT infrastructure.


I had no idea what kind of philosophical debate my answer would spark.

I posted my answer in the context of the question: Compare PowerShell to Cygwin and Perl and bash.

PowerShell is a shell, as it makes no syntactic difference between built-in commands, commandlets, user functions, and external commands (.exe, .bat, .cmd). Only invoking .Net methods differ by adding a namespace or an object in the call.

Its programmability derives from .Net framework, not from anything specific to the PowerShell "language".

I'd say I believe PowerShell is a "scripting language" as soon as Bugzilla or MediaWiki are implemented as PowerShell scripts running on a web server ;)

Until then, enjoy the comparisons.

share|improve this answer
Yeah, I guess when I'm talking about Unix "shell" I'm also referring to all the normal utilities that come with Unix, such as grep, awk, etc. I'm just wondering if PowerShell offers similar utilities out-of-the-box. –  Andy White Feb 21 '09 at 20:06
Powershell is not "just a shell". It is a scripting language. I wonder in what way it is not comparable to perl? I admit that it isn't as mature, but beyond that I don't see the disparity. –  EBGreen Feb 21 '09 at 23:11
@EBGreen, What exactly do you mean with this comment? I agree that any shell or scripting language is inherently similar, but I was wondering more about the specific capabilities of PowerShell vs. bash/perl/other unix shells/scripting languages. –  Andy White Feb 21 '09 at 23:33
Powershell has an incredibly wide range of functions. It is - A interactive, composable shell - A rich interactive scripting language - A programming language It has a rich set of OO & tesxt utility functions (i.e. equivalents to grep/awk/etc) as well. –  Jeffrey Snover - MSFT Feb 22 '09 at 0:28
@Andy - I understood Devio to say that powershell is not as powerful as Perl. I don't believe that is true and I just wondered why he thought that was the case. –  EBGreen Feb 22 '09 at 4:15

I have only recently started dabbling in PS with any degree of seriousness. Although for the past seven years I've worked in an almost exclusively Windows-based environment, I come from a Unix background and find myself constantly trying to "Unix-fy" my interaction experience on Windows. It's frustrating to say the least.

It's only fair to compare PS to something like Bash, tcsh or zsh since utilities like grep, sed, awk, find etc. are not, strictly speaking, part of the shell; they will always, however, be part of any Unix environment. That said, a PS command like Select-String has a very similar function to grep and is bundled as a core module in PS ... so the lines can be a little blurred.

I think the key thing is culture, and the fact that the respective tool-sets will embody their respective cultures:

  • Unix is a file-based, (in general, non Unicode) text-based culture. Configuration files are almost exclusively text files. Windows, on the other hand has always been far more structured in respect of configuration formats--configurations are generally kept in proprietary databases (e.g., the Windows registry) which require specialised tools for their management.
  • The Unix administrative (and, for many years, development) interface has traditionally been the command line and the virtual terminal. Windows started off as a GUI and administrative functions have only recently started moving away from being exclusively GUI-based. We can expect the Unix experience on the command line to be a richer, more mature one given the significant lead it has on PS, and my experience matches this. On this, in my experience:

    • The Unix administrative experience is geared towards making things easy to do in a minimal amount of key strokes; this is probably as a result of the historical situation of having to administer a server over a slow 9600 baud dial-up connection. Now PS does have aliases which go a long way to getting around the rather verbose Verb-Noun standard, but getting to know those aliases is a bit of a pain (anyone know of something better than: alias | where {$_.ResolvedCommandName -eq "<command>"}?).

      An example of the rich way in which history can be manipulated:

      iptables commands are often long-winded and repeating them with slight differences would be a pain if it weren't for just one of many neat features of history manipulation built into Bash, so inserting an iptables rule like the following:

      iptables -I camera-1-internet -s -m state --state NEW -j ACCEPT

      a second time for another camera ("camera-2"), is just a case of issuing:


      which means "perform the previous command, but substitute -1- with -2- and 50 with 51.

    • The Unix experience is optimised for touch-typists; one can pretty much do everything without leaving the "home" position. For example, in Bash, using the Emacs key bindings (yes, Bash also supports vi bindings), cycling through the history is done using Ctrl-P and Ctrl-N whilst moving to the start and end of a line is done using Ctrl-A and Ctrl-E respectively ... and it definitely doesn't end there. Try even the simplest of navigation in the PS console without moving from the home position and you're in trouble.

    • Simple things like versatile paging (ala less) on Unix don't seem to be available out-of-the-box in PS which is a little frustrating, and a rich editor experience doesn't exist either. Of course, one can always download third-party tools that will fill those gaps but it sure would be nice if these things were just "there" like they are on pretty much any flavour of Unix.
  • The Windows culture, at least in terms of system API's is largely driven by the supporting frameworks, viz., COM and .NET, both of-which are highly structured and object-based. On the other hand, access to Unix API's has traditionally been through a file interface (/dev and /proc) or (non-object-oriented) C-style library calls. It's no surprise then that the scripting experiences match their respective OS paradigms. PS is by nature structured (everything is an object) and Bash-and-friends file-based. The structured API which is at the disposal of a PS programmer is vast (essentially matching the vastness of the existing set of standard COM and .NET interfaces).

In short, although the scripting capabilities of PS are arguably more powerful than Bash (especially when you consider the availability of the .NET BCL), the interactive experience is significantly weaker, particularly if you're coming at it from an entirely keyboard-driven, console-based perspective (as many Unix-heads are).

share|improve this answer
You ask "anyone know of something better than: alias | where {$_.ResolvedCommandName -eq "<command>"}?". How about just alias -Definition *property (or any other pattern)? I think the problem with your answer is that you are conflating the shell and the console: remember you have a choice of consoles with different editing options. They deliberately left the DOS console editing broken to encourage people to use other consoles such as ISE. –  Duncan Feb 12 at 9:17
BTW, your !! example can be written in Powershell as (h -c 1) -replace '-1-','-2-' -replace '50','51' | iex but it's easier to up arrow and edit for a single command. If you want to do it across a lot of commands I think Powershell would win. To repeat 10 commands ending at command #255 with your edits: (h -c 10 -id 255) -replace '-1-','-2-' -replace '50','51' | iex Also Powershell's history lets you do things unheard of in Linux shells; if you wonder retrospectively just how long a command took to run: h -id 20 | select { $_.EndExecutionTime - $_.StartExecutionTime } –  Duncan Feb 12 at 9:32
@Duncan In respect of your comment re the shell and the console--I think that that's just a fundamental difference between Bash and PS; that is: Bash expects to deliver a certain interactive experience whereas PS "leaves" that to something else. I don't have a lot of experience with the ISE console, but from I can remember, it doesn't have a tremendously rich interactive experience either. –  Eric Smith Feb 14 at 13:21
@Duncan, yes - good point about the ability of PS to deliver in respect of clever history tricks. –  Eric Smith Feb 14 at 13:24
@Duncan ... but despite your assertion that some things are unheard of in Linux shells: fc -e "sed -i -e 's/-1-/-2-/g' -e 's/50/51/g'" 10 255 –  Eric Smith Feb 14 at 13:56

If you like shell scripting you will love PowerShell!

Start at A guided tour of the Microsoft Command Shell (Ars Technica).

share|improve this answer
I'm not sure about your conclusion - but the article looks useful. Thanks. –  Jonathan Leffler Feb 21 '09 at 21:47
I love shell scripting and I tolerate PowerShell. It's commands and syntax are atrocious. Horribly long commands and options without any useful command completion. Or if there is I haven't found it. Too many features crammed into single commands that should be separated out. Weird variable and escape syntax only a DOS batch programmer could love. –  Zan Lynx Jun 24 '10 at 5:32
@Zan Lynx - You are right about not having found stuff. All commands have aliases, and many of them match both DOS and UNIX commands ( ps, dir, rm, ls, kill, history, man, cat, clear etc.) The names are long so that they have a meaningful name. Great for scripts -it helps when a new person has to use and maintain it. There is tab expansion for cmdlets, functions, variable, path, parameters etc. Much of the syntax is from Unix shells and what escape syntax are you talking about? `` is not used for escape since it is the path separator in Windows. –  manojlds Aug 24 '11 at 4:49
@Zan Lynx - Your arguments are not valid. To stop interpreting variables, use ' (single quotes). To the double double quotes thing - same, use write-output 'this is a "test"'. The question you are pointing to is for Regex and the escaping for regex is valid everywhere. Powershell has Here-Strings / verbatim strings as well. Even Java doesn't have these! Try escaping regex in Java. And you don't sometimes use literalpath. You use when you need to. LiteralPath treats wildcard characters verbatim and doesn't expand them. You use it when your files have it. It gives you more options. –  manojlds Aug 24 '11 at 5:41
@manojlds: Compared to the bash shell, Powershell is full of inconsistencies that make no sense and are just confusing. In bash you use the same escape character everywhere and file paths are escaped just as strings are. You don't need a special parameter for it. If you expand a variable that has special characters in it, you put it in double quotes and the contents are safe, no need to call a function to re-escape it. –  Zan Lynx Aug 24 '11 at 5:46

I haven't seen that the Powershell has really taken off, at least not yet. So it might not be worth the effort of learning it unless those others on your team already know it.

For your predicament you might be better off with a scripting language that others could get behind, Perl like you mentioned, or others like Ruby or Python.

I think a lot of it depends on what you need to do. Personally I've been using Python for my own personal scripts, but I know when I start writing something that I'll never be able to pass it on - so I try not to do anything too revolutionary.

share|improve this answer

The cmdlets in powershell are very nice and work reliably. Their object-orientedness appeals to me a lot since I'm a java/C# developer, but it's not at all a complete set. Since it's object oriented, it's missed out on a lot of the text stream maturity of the POSIX tool set (awk and sed to name a few).

The best answer I've found to the dilemma of loving OO techniques and loving the maturity in the POSIX tools is to use both! One great aspect of Powershell is that it does an excellent job piping objects to standard streams. Powershell by default uses an object pipeline to transport its objects around. These aren't the standard streams (standard out, standard error, and standard in). When Powershell needs to pass output to a standard process that doesn't have an object pipeline, it first converts the objects to a text stream. Since it does this so well, Powershell makes an excellent place to host POSIX tools!

The best POSIX tool set is GnuWin32. It does take more than 5 seconds to install, but it's worth the trouble, and as far as I can tell, it doesn't modify your system (registry, c:\windows\* folders, etc.) except copying files to the directories you specify. This is extra nice because if you put the tools in a shared directory, many people can access them concurrently.

GnuWin32 Installation Instructions

Download and execute the exe (it's from the SourceForge site) pointing it to a suitable directory (I'll be using c:\bin). It will create a GetGnuWin32 directory there in which you will run download.bat, then install.bat (without parameters), after which, there will be a c:\bin\GetGnuWin32\gnuwin32\bin directory that is the most useful folder that has ever existed on a Windows machine. Add that directory to your path and you're ready to go.

share|improve this answer

TL;DR -- I don't hate Windows or Powershell I just can't do anything in windows or on Powershell.

I personally still find powershell underwhelming at best.

  • tab completion of directory paths do not compound, requiring the user to enter a path separator after every name completion.
  • I still feel like windows doesn't even the concept of path or of what a path is, with no accessible user home indicator ~/ short of some @environment://somejibberish/%user_home%
  • NTFS is still a mess and seemingly always will be, good luck navigating.

  • cmd-esque interface, The dinosaur cmd.exe is still visible in Powershell, edit->mark still being the only way to copy information, and copying only in the form of rectangular blocks of visible terminal space. and edit->paste still being the only way to paste strings into the terminal.

  • Painting it blue doesn't make it any more attractive. I don't mind MS developers having a taste in color though.

  • Windows always opens at top left corner of screen, For somebody who uses vertical task bars this is incredibly annoying, especially considering that the windows task bar will cover the only corner of the window that gives access to copy/paste functionality.

I can't speak much on the grounds of the tools windows includes. Being that there is a whole set of open-source, freely licensed cli tools, and powershell ships with, to my knowledge, none of them is an utter disappointment.

  • powershell wget takes seemingly incomparable arguments to gnu wget, thanks glimmer of hope portably-useless.
  • powershell posix is not bash-compatible, particularly the && operator is not handled, making the simplest of conditional command following not a thing.

I dunno man, I gave it a shot, I really did; I still try to give it a shot in the hopes that the next time I open it it will be any less useless. I cannot do anything in powershell, and I can bearly do things with a real project to bring gnu tools to Windows.

MySysGit gives me the dinosaur cmd.exe prompt with a couple gnu tools, still very underwhelming, but at last path completion works. and git command will run in gitBash

Mintty for MySysGit gives the Cygwin interface over mysysgit's environment, making copy and paste a thing. (select to copy (mouse), shift+ins to paste, how modern...) however, things like git push are broken in Mintty.

I don't mean to rant, but I still see huge problems with command-line usability on windows even given tools like Cygwin.

P.S. Just cause something can be done in powershell, doen't make it usable, usability is deeper than ability and is what I tend to focus on when trying to use a product as a consumer.

share|improve this answer
Turn on QuickEdit mode? Select and press enter to copy, ctrl-v to paste, no more Edit->Mark or Edit->Paste. While in the preferences, set the Window position and untick "let system position window". Tab completion is not just completing filesystem paths, it's also completing variable names, command names, object properties, you might be about to type . or [ to access a property or index, so it can't just add a path separator on the end. Which PowerShell wget, exactly? Which PowerShell POSIX? It's not trying to bring gnu tools to Windows, or be bash-compatible btw. –  TessellatingHeckler Mar 27 at 0:22
Yeah i know it's not trying to be bash. I refrained from saying so in the original post. I would say which w get binary but there is no "which" command in power shell :( i don't recall where buy i read power Shell was supposed to be POSIX compatible –  ThorSummoner Mar 27 at 0:31
re: "no which" -> (get-command wg*.exe).Path. Re: bash completion and readline -> leeholmes.com/blog/2012/09/13/… leading to github.com/lzybkr/PSReadLine –  TessellatingHeckler Mar 27 at 5:14

PowerShell is very powerful, more powerful than the standard built-ins of the Unix shells (but only because it includes much of the functionality usually shelled out to subprograms). Also, consider that you can write applets in any .NET language, including IronPython, IronRuby, PerlNet, etc.. or you can simply call your cygwin commands from PowerShell, ignoring all the extra functionality and it will work similarly to bash, korn, or whatever...

share|improve this answer
I think you may be missing the design goals of Unix shells. Not knocking PowerShell (would like to learn more myself) but you need to understand Unix tooling to make a statement like that. –  Xepoch Jan 7 '11 at 17:24
@Xepoch - No, I think you're missing the design goals of PowerShell. PowerShell can do everything the Unix shells can do in the same way that they do it. However, the real power comes when you utilize PS's object piping system rather than just parsing text output. So, PowerShell can do exactly what bash or korn can do, but they can't do what PowerShell can do. –  Erik Funkenbusch Jan 7 '11 at 17:31
I simply don't know PowerShell enough to give you a critique thereon, but as you clearly know the goals of the Unix shells are not necessarily a fully comprehensive replacement of external tooling, rather the control structures around it. Again I cannot at this time compare nor contrast but elevating PowerShell because it has more built-ins is not necessarily the boon of the Unix shells. –  Xepoch Jan 7 '11 at 18:07
@Xepoch - The point is, you can choose which way you want to do it. You can use all the goodness of the built-in shell, or you can ignore and do it the way Unix does it. It's your choice. And choice is good, right? –  Erik Funkenbusch Jan 7 '11 at 18:08

You can also try running Bash scripts on windows using BashWin at https://github.com/skanga/BashWin

share|improve this answer

I found PowerShell programming to be not worth the effort.

I have several years of experience with shell scripting under Unix, but I found it enormously difficult to do much of anything with PowerShell.

It seems like many functions require you to interrogate the Windows Management Interface and issue SQL-like commands to get the information you need.

For example, I wanted to write a script to remove all files with a specific suffix from a directory tree. Under Unix, this would be a simple ...

find . -name \*.xyz -exec rm {} \;

After a couple of hours dicking around with Scripting.FileSystemObject and WScript.Shell and issuing "SELECT * FROM Win32_ShortcutFile WHERE Drive = '" & drive & "' AND Path = '" & searchFolder & "'", I finally gave up and settled for Windows Explorer's Search command and just do it manually. There's probably some way to do what I wanted, but I didn't see anything obvious and all the examples on the MSDN site were so trivial as to be worthless.

EDIT Heh, of course as soon as I wrote this I poked around some more and found what I had been missing: the -recurse option to the remove-item command is faulty (revealed if you use get-help remove-item -detailed).

I had been trying "remove-item -filter '* .xyz' -recurse" and it wasn't working, so I gave up on it.

Turns out you need to use get-childitem -filter '*.xyz' -recurse | remove-item

share|improve this answer
I think you're confusing Windows Scripting Host (WSH) with PowerShell. They're totally different. –  Erik Funkenbusch Feb 22 '09 at 3:05
As an example, if you want to delete all the files that end in .TMN you can issue this command get-childitem c:\ -include *.TMN -recurse | foreach ($_) {remove-item $_.fullname} –  Erik Funkenbusch Feb 22 '09 at 3:10
@Mystere: I tried this, and it didn't seem to work. After some futzing about, it seems that *.tmn is what you need (instead of just .tmn) –  redtuna Jun 23 '10 at 20:47

In a couple of lines, Cygwin and Powershell are different tools however if you have Cygwin installed you can run the Cygwin executables within a Powershell session. I've gotten so used to Powershell that now I no longer use grep, sort, awk, etc. There are pretty much built-in alternatives in Powershell, and if not you can find a cmdlet out there.

The main tool I find myself using is ssh.exe but within a Powershell session.

Works great.

share|improve this answer

Why not use both? Call PowerShell scripts in Cygwin just like any other interpreted scripts like perl, etc.

I do this enough that I wrote https://bitbucket.org/jbianchi/powershell for a bash wrapper to call powershell.exe in Cygwin. Can be used as a Shebang as the first line of a powershell.exe .ps1 script (since powershell also uses "#" as a comment). See https://bitbucket.org/jbianchi/powershell/wiki/Home for examples

share|improve this answer

protected by Community Jul 13 '12 at 12:20


Would you like to answer one of these unanswered questions instead?
